HTML and CSS Reference
uppercase letters, by convention only. Constants are assigned values at the time of the
declaration, and it is impossible to modify them during the run of the program. Caveat:
keyword const to declare constants (see Figure 3.7). It is important to note that Internet
Explorer 7 and 8 do not support it, as shown in Figure 3.8.
<head><title>Using the const Keyword</title>
const NOON = 12;
const FREEZING = 32;
// Can't change
document.write("Farenheit temp is " + FREEZING + ".<br />");
FREEZING = 32 + 10;
NOON = NOON + " noon";
document.write("Make it warmer " + FREEZING + ".<br />");
document.write("See you at ", NOON , ".<br />");
The constant NOON is assigned 12, a value that will not change throughout the
execution of this program.
The constant FREEZING is assigned 32, a value that will not change throughout
the execution of this program.
Now if we try to add 10 to the constant, the value of the constant doesn't change.
It's still 32.
This time, we try to concatenate a string to the constant NOON. It will not be
The constants FREEZING and NOON are displayed. They were not changed.