Prev Demo
Const Variable In Javascript
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script> const myAge = 9; const person = { name: "Sheo", age: myAge } alert(person.name + ' ' + person.age); // Error myAge = 10; // error person = { // error name: "Sheo Narayan", age: myAge }; // however the const object property value can be changed person.name = "Narayan"; person.age = 60; alert(person.name + ' ' + person.age); </script> </head> <body> <p>const variable in JavaScript</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output