Mathias Bynens 2/4/2016

ES2015 `const` is not about immutability

Read Original

This article debunks the widespread misunderstanding that the ES2015 `const` keyword makes values immutable. It explains that `const` only creates an immutable binding, preventing variable reassignment, but the value itself (like an object's properties) can still change. The author contrasts `const` with `let`, demonstrates how to achieve true immutability using `Object.freeze()`, and advocates for using `const` by default in modern JavaScript.

ES2015 `const` is not about immutability

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week