DEV Community

Discussion on: ES6 Mini Crash Course: How to Write Modern JavaScript

Collapse
 
georgecoldham profile image
George

Just remember that while you may be using const in a static context, it is still a mutable value.

Collapse
 
chrisachard profile image
Chris Achard

Yes, good point (I actually almost included a warning in there, but too many warnings and it would no longer be a "mini" crash course 😂)

Here's a good example:

const myObject = { value: "abc" };
myObject.value = "123";
console.log(myObject); // {value: "123"}

So yes - if you really need immutability, then you have to use another library, like: github.com/immutable-js/immutable-js