Constants In JavaScript
We can create constants in JavaScript using ‘const’ keyword.
[js]
const name = ‘Sakshi’
console.log(name)
[/js]
This will print: Sakshi
Now, if we try to change or re-initialize ‘name’ constant, the value will not change.
[js]
const name = ‘Hello’
console.log(name)
[/js]
This will again print: Sakshi
Compatibility: ‘const’ is supported in Firefox & Chrome. Some compatibility issue with Internet Explorer 10 and lower, opera and some other browsers. It is going to be defined by ECMAScript 6 soon.