We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不存在变量提升 这一节结尾对typeof的解释可能引起歧义,这里typeof x 报错的原因并不是不存在变量提升和**x还没有声明**,而是因为下面的let x导致的暂时性死区。单独一句typeof x并不会报错,关于typeof的这一段移到下一节比较好。
typeof
typeof x
x
let x
const命令 中的这一段:
const foo; // SyntaxError: missing = in const declaration 上面代码表示,对于const来说,只声明不赋值,就会报错。
const foo; // SyntaxError: missing = in const declaration
上面代码表示,对于const来说,只声明不赋值,就会报错。
const不赋值的话,只有在严格模式下才会报错。
const
另外下面的:
```javascript const foo = Object.freeze({}); foo.prop = 123; // 不起作用 ``` 上面代码中,常量foo指向一个冻结的对象,所以添加新属性不起作用。
给冻结对象添加属性,在常规模式下是不起作用,在严格模式下则会报错。 结合这两段代码示例,前者运行在严格模式,后者运行在常规模式,而不同摸下的结果都不同,我觉得全书的示例最好统一到一个模式下,或者单独标明是哪种模式。
The text was updated successfully, but these errors were encountered:
谢谢指出,说得很正确,我已经改过来了。
Sorry, something went wrong.
No branches or pull requests
不存在变量提升 这一节结尾对
typeof
的解释可能引起歧义,这里typeof x
报错的原因并不是不存在变量提升和**x
还没有声明**,而是因为下面的let x
导致的暂时性死区。单独一句typeof x
并不会报错,关于typeof的这一段移到下一节比较好。const命令 中的这一段:
const
不赋值的话,只有在严格模式下才会报错。另外下面的:
给冻结对象添加属性,在常规模式下是不起作用,在严格模式下则会报错。
结合这两段代码示例,前者运行在严格模式,后者运行在常规模式,而不同摸下的结果都不同,我觉得全书的示例最好统一到一个模式下,或者单独标明是哪种模式。
The text was updated successfully, but these errors were encountered: