在JavaScript中声明和初始化变量之间有什么区别?
以下是关于ECMAScript规范中变量的声明和初始化的说明-
A var statement declares variables that are scoped to the running execution context’s VariableEnvironment. Var variables are created when their containing Lexical Environment is instantiated and are initialized to undefined when created. [...] A variable defined by a VariableDeclaration with an Initializer is assigned the value of its Initializer’s AssignmentExpression when the VariableDeclaration is executed, not when the variable is created.
上面定义了区别:
所有变量均使用未定义的值初始化。
变量声明在其词法环境初始化时使用undefined初始化。
此初始化不能作为分配。
热门推荐
10 经典送别祝福语大全简短
11 鲜花卡片简短开业祝福语
12 画室蛋糕祝福语简短英文
13 生日果酒祝福语简短独特
14 新进单位敬酒祝福语简短
15 同事入新家祝福语简短
16 中式蛋糕开业祝福语简短
17 婚礼西装祝福语简短男士
18 朋友孩子考试祝福语简短