DEV Community

Discussion on: What's the difference between var, const and let

Collapse
 
thenickest profile image
TheNickest

Doesn’t the const key word make a variable a constant? Like: if we assign a value with const, we assign it to a constant and not to an immutable variable. I was always wondering.

Collapse
 
johnpalmgren profile image
John Palmgren

That's right. When you use the const keyword javasctipt will expect that that value won't change. And in fact, will throw an error if you try to update it.