Question

In Google Style guide for JavaScript written (prove link), that using a "const" construction is a bad practice, why?

Was it helpful?

Solution

Because it is not standard (yet). It's a JavaScript 1.5 keyword, not ECMAScript. From the MDN documentation:

The current implementation of const is a Mozilla-specific extension and is not part of ECMAScript 5. It is supported in Firefox & Chrome (V8) and partially supported in Opera 9+ and Safari. It is not supported in Internet Explorer 6-9, or in the preview of Internet Explorer 10. The const keyword currently declares the constant in the function scope (like variables declared with var).

Also if you read the section you linked to carefully, the last sentence is:

As for the const keyword, Internet Explorer doesn't parse it, so don't use it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top