问题:
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
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4478971