DEV Community

Discussion on: Javascript Variable Assignments

Collapse
 
elmuerte profile image
Michiel Hendriks

when declaring with const is that the values can not be changed once they have been declared, can not be re-assigned

Values can be changed. Just the assignment cannot.

const foo = {
  "bar": false
};
foo.bar = true;
console.log(foo.bar); // prints true
Enter fullscreen mode Exit fullscreen mode

In other languages which offer const it is actually constant and cannot be changed (e.g. C, C++, also C# but limited).