var关键字的目的是什么?何时应使用(或省略)?

情到浓时终转凉″ 提交于 2020-10-27 07:15:25

问题:

NOTE : This question was asked from the viewpoint of ECMAScript version 3 or 5. The answers might become outdated with the introduction of new features in the release of ECMAScript 6. 注意 :从ECMAScript版本3或5的角度提出了此问题。随着ECMAScript 6版本中引入新功能,答案可能会过时。

What exactly is the function of the var keyword in JavaScript, and what is the difference between JavaScript中var关键字的功能到底是什么,它们之间有什么区别

var someNumber = 2;
var someFunction = function() { doSomething; }
var someObject = { }
var someObject.someProperty = 5;

and

someNumber = 2;
someFunction = function() { doSomething; }
someObject = { }
someObject.someProperty = 5;

?

When would you use either one, and why/what does it do? 您什么时候会使用其中一个?为什么/会做什么?


解决方案:

参考一: https://stackoom.com/question/6AXY/var关键字的目的是什么-何时应使用-或省略
参考二: https://oldbug.net/q/6AXY/What-is-the-purpose-of-the-var-keyword-and-when-should-I-use-it-or-omit-it
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!