DEV Community

Discussion on: Start Javascript: learn about variables

 
mindsers profile image
Nathanaël CHERRIER

The 'thing' that the constant is 'storing' cannot be changed to a different 'thing'.

This is the fundamental difference between 'variables' and 'constants' and should be taught right from the start so as to avoid any confusion later.

When the article say:

The value you'll give to a constant is the only value it will stock until its deletion.

It's not clear enough?

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️ • Edited

The issue is with referring to a constant as a variable. This is simply wrong and generates unnecessary confusion. Your description of the behaviour of a constant however, is completely acceptable

Thread Thread
 
mindsers profile image
Nathanaël CHERRIER

Then, you can start a proposal to change that in the TC39 and Ecma 262 specifications because they are currently referring to a constant as a variable:

let and const declarations define variables that are scoped to the running execution context's LexicalEnvironment.

source: tc39.es/ecma262/#sec-let-and-const...

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️

A javascript specification (that defines at a technical level the way a const is implemented in the language) and how best to teach programming concepts to beginners are 2 entirely different things :)