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?
(您什么时候会使用其中一个?为什么/会做什么?)
ask by Alex translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…