Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- //Here you get an error when trying to change AGE because AGE is a constant value and can not be changed once set.
- /*
- * const AGE = 27;
- * AGE = 29;
- * console.log(AGE);
- */
- // Here we can change the value of age because an object is a reference type, the pointer didn't change, only the value.
- const OBJ = {
- age: 27
- };
- console.log(OBJ);
- OBJ.age = 30;
- console.log(OBJ);
- </script>
- <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.
- /*
- * const AGE = 27;
- * AGE = 29;
- * console.log(AGE);
- */
- // Here we can change the value of age because an object is a reference type, the pointer didn't change, only the value.
- const OBJ = {
- age: 27
- };
- console.log(OBJ);
- OBJ.age = 30;
- console.log(OBJ);</script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement