DEV Community

Discussion on: What changes can be made with `const`

Collapse
 
peerreynders profile image
peerreynders • Edited

const is used when the value does not change

reinforces a faulty mental model

let value = 123;
value = 456;
Enter fullscreen mode Exit fullscreen mode

i.e. that value is a place and the 456 replaces 123 in that place - when in fact value is simply a name that refers to the place where 123 is and that name can later refer to a different place where 456 is. So with

const value = 123;
Enter fullscreen mode Exit fullscreen mode

value can only ever refer to one and the same place - the one where 123 is.

Thread Thread
 
ml318097 profile image
Mehul Lakhanpal

See no turns to an expert at day 1. People have to then understand that is a reference and a value. Everything has a dependency. And just reading it once won't build a model. Everyone has to study, practice and learn regularly to get good at anything.