What are some reasons to use var instead of let in javascript? [duplicate]

倾然丶 夕夏残阳落幕 提交于 2021-01-27 04:00:35

问题


With the new keyword let for declaration of variables in javascript ES6, I can no longer think of good reasons to use var. So far, I have been doing just that and I do not see any disadvantage of using let ALL THE TIME.

What are good reasons to use var today? Is it a good practice to use let all the time today?


回答1:


IMO there is no definite advantage of using var over let, other than for its scope. One reason might be to support older browsers perhaps (if you don't plan to use an ES6 to ES5 compiler like Babel).



来源:https://stackoverflow.com/questions/41031342/what-are-some-reasons-to-use-var-instead-of-let-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!