const
is a proposed feature of ECMAScript Harmony (together with a properly block-scoped let
it is supposed to replace var
and implicit globals). ECMAScript Harmony is a grab-bag of ideas for the next versions of ECMAScript.
const
was also a part of ECMAScript 4.
ECMAScript 4 was never released and never will be, and ECMAScript Harmony will only be released in a couple of years. Therefore, you cannot reliably use it.
There are some implementations or derivatives of ECMAScript that implement const
(ActionScript, for example). There are also some implementations that accept const
as a synonym for var
(IOW, you can use const
, but it won't give you any protection.)
However, unless you absolutely can guarantee that your code will only run on very specific versions of very specific implementations of very specific derivatives of ECMAScript, it's probably better to avoid it. (Which is a real shame, because const
and especially let
are a huge improvement over var
and implicit globals.)