Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  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. //Here you get an error when trying to change AGE because AGE is a constant value and can not be changed once set.
  12.  
  13. /*
  14. * const AGE = 27;
  15. * AGE = 29;
  16. * console.log(AGE);
  17. */
  18.  
  19.  
  20. // Here we can change the value of age because an object is a reference type, the pointer didn't change, only the value.
  21. const OBJ = {
  22. age: 27
  23. };
  24.  
  25. console.log(OBJ);
  26. OBJ.age = 30;
  27. console.log(OBJ);
  28. </script>
  29.  
  30.  
  31.  
  32. <script id="jsbin-source-javascript" type="text/javascript">//Here you get an error when trying to change AGE because AGE is a constant value and can not be changed once set.
  33.  
  34. /*
  35. * const AGE = 27;
  36. * AGE = 29;
  37. * console.log(AGE);
  38. */
  39.  
  40.  
  41. // Here we can change the value of age because an object is a reference type, the pointer didn't change, only the value.
  42. const OBJ = {
  43. age: 27
  44. };
  45.  
  46. console.log(OBJ);
  47. OBJ.age = 30;
  48. console.log(OBJ);</script></body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement