Immutable variables in ES6

      No Comments on Immutable variables in ES6

Immutable variables also know as “constants” in ES6.

const stupid=22;

const is not fully immutable. A constant value can change in following condition.

const stupid={};


console.log(stupid.job); // programmer

Only thing immutable here is binding.

Following thing throws error while changing the value of a variable

const stupid=22;

stupid=23; //Uncaught TypeError: Assignment to constant variable.





Leave a Reply

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