Constants In JavaScript

22 / Jan / 2014 by Sakshi Tyagi 0 comments

We can create constants in JavaScript using ‘const’ keyword.

const name = 'Sakshi'
console.log(name)

This will print: Sakshi
Now, if we try to change or re-initialize ‘name’ constant, the value will not change.

const name = 'Hello'
console.log(name)

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.

Tag -

FOUND THIS USEFUL? SHARE IT

Leave a comment -