To answer the question directly - no, you can't, because of the compatibility issues, as @suraj kindly reminded us.
Having said that, in the modern JS development you are increasingly unlikely to use var
as let
and const
have clear advantages, apart from some specific uses of var
and will use either BabelJS, TypeScript or even now Webpack 2 to transpile the code for backward compatibility as the production code will be shipped in vanilla JS. Modern IDEs, like WebStorm, will even lint your var
's by default in ES6 mode to change them to let
.
Judging from the question, you are still in the process of studying JS and you are already asking the right questions, so I would recommend to use today let
and const
to utilize the advantages of ES6, but that would add the complexity of dealing with the transpilers. But if you are OK with that - this is the way to go.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…