DEV Community

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

georgecoldham profile image

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

chrisachard profile image
Chris Achard Author

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: