Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 13th, 2018 86 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width">
  6.   <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. const ob1 = {
  12.   a: 1,
  13.   b: 2
  14. };
  15.  
  16. console.log(ob1);
  17.  
  18. const ob2 = {
  19.   nested: {
  20.     nestedDeeper: {
  21.       nestedDeepest: {
  22.         num1: ob1.a,
  23.         num2: ob1.b
  24.       }
  25.     }    
  26.   }
  27. };
  28.  
  29. // obj2.nested.nestedDeeper.nestedDeepest got referenced values.
  30. console.log(ob2.nested.nestedDeeper.nestedDeepest);
  31.  
  32. // We change ob1.a and hope that ob2.nestedDeeper.nestedDeepest.num1 has changes.
  33. ob1.a = 'ob1.a changed';
  34.  
  35. // ob1 is changed
  36. console.log(ob1);
  37.  
  38. // obj2.nested.nestedDeeper.nestedDeepest is not changed.
  39. console.log(ob2.nested.nestedDeeper.nestedDeepest);
  40. </script>
  41.  
  42.  
  43.  
  44. <script id="jsbin-source-javascript" type="text/javascript">const ob1 = {
  45.   a: 1,
  46.   b: 2
  47. };
  48.  
  49. console.log(ob1);
  50.  
  51. const ob2 = {
  52.   nested: {
  53.     nestedDeeper: {
  54.       nestedDeepest: {
  55.         num1: ob1.a,
  56.         num2: ob1.b
  57.       }
  58.     }    
  59.   }
  60. };
  61.  
  62. // obj2.nested.nestedDeeper.nestedDeepest got referenced values.
  63. console.log(ob2.nested.nestedDeeper.nestedDeepest);
  64.  
  65. // We change ob1.a and hope that ob2.nestedDeeper.nestedDeepest.num1 has changes.
  66. ob1.a = 'ob1.a changed';
  67.  
  68. // ob1 is changed
  69. console.log(ob1);
  70.  
  71. // obj2.nested.nestedDeeper.nestedDeepest is not changed.
  72. console.log(ob2.nested.nestedDeeper.nestedDeepest);</script></body>
  73. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top