JavaScript const keyword
const
keyword always creates a value which is scoped to the block in which it is declared.- Values created using
const
are not mutable by value or reference. - So, all primitive values created using
const
can never be replaced by another value. - For non primitive values like
objects
andarrays
, their references cannot be changed, but still they can be mutated.
This 4th point has always been tricky for new comers to JavaScript.