Hi Bill,
Keith Ensign

A quick note about the immutability of const (or lack thereof)

I’m glad you found my article helpful, I just wanted to clarify a small point regarding const in ES2015. Unfortunately, a const can indeed be mutated.

The following is perfectly legal in ES2015:

const foo = [];

All the const declaration does is prevent re-assignment which is not the same as preventing mutation.

The following works fine in ES2015 as well and is totally legal:

const foo= { bar: ‘bar’ };
foo.bar = ‘baz’;

These days, I tend to use Immutable.js to get true immutability.

Like what you read? Give Bill Sourour a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.