We are considering adopting the Google JavaScript coding guidelines within our company to maintain consistency across projects but one thing is confusing me. In the section on constants it says to use the @const keyword annotation for compile-time constant enforcement but I have never come across the @ symbol before. Is this a Google extension or part of the core language?
Here is the full text:
For non-primitives, use the
@constannotation.
/**
* The number of seconds in each of the given units.
* @type {Object.<number>}
* @const
*/
goog.example.SECONDS_TABLE = {
minute: 60,
hour: 60 * 60
day: 60 * 60 * 24
}
This allows the compiler to enforce constant-ness.
As for the
constkeyword, Internet Explorer doesn't parse it, so don't use it.