DEV Community

Discussion on: Var vs let and const; easy as pie

Collapse
 
danoswalt profile image
Dan Oswalt

One other small but important thing is that const only means immutable, never can be changed, for primitive values.

This is not the case for objects and arrays! The properties can change. It refers to reference in memory. I'm not sure if there's any reason not to favor let for objects and arrays for this reason. Save const for primitives. It's a clearer signal to other devs of what is truly constant.

Collapse
 
brettthurs10 profile image
Brett Thurston

You are absolutely correct Dan! I call it the sneaky const array, 😂. I forgot to mention that in this article, but I'll update it soon. Kudos!