DEV Community

Discussion on: Javascript variables - var, let and const.

Collapse
 
remotesynth profile image
Brian Rinaldi

const is a little more complex than what you have here. The reference is immutable, but the value is not. So something like...

const foo = { bar: "bar" };
foo.bar = "foo";

...will not generate an error.

If this all confuses you a bit like it does me, tools like JSLint can help you determine when it may be more appropriate to change a let to a const. 😀

(Also, sorry for the self-promotion, but since the other commenter mentioned Kyle Simpson and it is relevant to your post, I am running an online training on JavaScript language fundamentals that features Kyle and 3 other fantastic trainers - knowjs.org)