DEV Community

Cover image for Javascript Variable Assignments

Javascript Variable Assignments

Oscar Ortiz on June 19, 2021

Introduction If you wanna get a bit more in depth on the differences between the ways of declaring variables with var, let, and const, ...
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).