Constants In JavaScript

22 / Jan / 2014 by Sakshi Tyagi 0 comments

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.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *