源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

JavaScript Scoping and Hoisting 翻译

  • 时间:2020-08-08 02:48 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:JavaScript Scoping and Hoisting 翻译
你知道下面的JavaScript代码执行后会alert出什么值吗?
[url=http://www.mozilla.org/js/language/E262-3.pdf]ECMAScript Standard (pdf)[/url]来理解这些东西是如何运作的总是很有用。下面是关于变量声明和作用域的一段摘录(section 12.2.2): If the variable statement occurs inside a FunctionDeclaration, the variables are defined with function-local scope in that function, as described in section 10.1.3. Otherwise, they are defined with global scope (that is, they are created as members of the global object, as described in section 10.1.3) using property attributes { DontDelete }. Variables are created when the execution scope is entered. A Block does not define a new execution scope. Only Program and FunctionDeclaration produce a new scope. Variables are initialised to undefined when created. A variable with an Initialiser is assigned the value of its AssignmentExpression when the VariableStatement is executed, not when the variable is created. 我希望这篇文章能够给JavaScript程序员最容易困惑的部分一些启示。我尽力写的全面,以免引起更多的困惑。如果我写错了或是漏掉了某些重要的东西,请一定让我知道。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部