DEV Community

Discussion on: const, let, var; JavaScript variables and immutability

Collapse
 
savagepixie profile image
SavagePixie • Edited

var and let are mutable values

However, const does not allow reassignment of the reference, nor does it allow the mutation of a primitive.

Actually all promitives are always immutable in JavaScript, whereas referential types are mutable. Mutability in JavaScript is not related to the variable keyword but to the value's type.

The difference between let and const is about reassignability, not mutability.

Collapse
 
jmitchell38488 profile image
Justin Mitchell • Edited

Good point I'll update the language around that.