2.4. Constants: Named but Not VariablesThere are times when you'll want to define a value once, and then have it treated as a read-only value from that time forward. The keyword const is used to create a JavaScript const: const CURRENT_MONTH = 3.5; The constant can be of any value, and since it can't be assigned or reassigned a value at a later time, it's initialized to its constant value when defined. Just as with variables, a JavaScript constant has global and local scope. I use constants at a global level, primarily because they contain a value I want to be accessible (and unchanged) by a JavaScript block. |