在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 虎年男孩出生祝福语简短