Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why using "const" construction in JavaScript is a bad practice?

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

like image 894
NiLL Avatar asked May 31 '26 10:05

NiLL


1 Answers

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.

like image 132
Felix Kling Avatar answered Jun 02 '26 00:06

Felix Kling



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!