DEV Community

loading...

Discussion on: Confused by JavaScript's const? Me too!

Collapse
georgecoldham profile image
George

You should check out Object.freeze if you want const to be immutable or Object.seal if you want const to just be a little bit mutable.

Collapse
remotesynth profile image
Brian Rinaldi Author

Thanks. Yes, I didn't bring them up because I thought it might sidetrack the discussion of const a bit but if immutability really matters for what you are doing, then definitely.

Collapse
georgecoldham profile image
George

I had always assumed they were immutable, was shocked to find they weren't.

The immutability was the key reason I started to use them.