Is there a reason not to give up "var"?

In the process of learning JavaScript, I learned that I was introduced Letand constto fix problems Varwith respect to the global scope and rise and not to give an error when re-declaring.

Now can I write code completely without using Var? or should I know about them now and wait for them to become widely "acceptable"?

In other words, while I have to worry about compatibility issues, if I used only Letand const?

+6
source share
1 answer

To answer the question directly - no, you cannot because of compatibility issues, as @suraj kindly reminded us.

Having said that in modern JS development you are unlikely to use it var, since letthey consthave obvious advantages, in addition to some specific applications var, they will use either BabelJS, TypeScript or even now Webpack 2 to convert the code for backward compatibility, since the production code will be sent to vanilla js. Modern IDEs such as WebStorm will by default embed varin ES6 mode to change them to let.

, JS, , let const ES6, . - .

+3

Source: https://habr.com/ru/post/1016294/


All Articles