October 2015
Beginner to intermediate
400 pages
14h 44m
English
Constants are expressions whose value is known to the compiler and whose evaluation is guaranteed to occur at compile time, not at run time. The underlying type of every constant is a basic type: boolean, string, or number.
A const declaration defines named values that look syntactically like
variables but whose value is constant, which prevents
accidental (or nefarious) changes during program execution. For
instance, a constant is more appropriate
than a variable for a mathematical constant
like pi, since its value won’t change:
const pi = 3.14159 // approximately; math.Pi is a better approximation
As with variables, a sequence of constants can appear in one declaration; this would be appropriate ...