var and let are mutable values However, const does not allow reassignment of the reference, nor does it allow the mutation of a primitive.
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.
let
const
Good point I'll update the language around that.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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
andconst
is about reassignability, not mutability.Good point I'll update the language around that.