1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

docs(let): fix #1001

This commit is contained in:
ruanyf 2020-08-06 19:56:54 +08:00
parent 064ee65efc
commit e78513744c

View File

@ -601,7 +601,7 @@ JavaScript 语言存在一个顶层对象,它提供全局环境(即全局作
同一段代码为了能够在各种环境,都能取到顶层对象,现在一般是使用`this`变量,但是有局限性。
- 全局环境中,`this`会返回顶层对象。但是Node 模块和 ES6 模块中,`this`返回的是当前模块
- 全局环境中,`this`会返回顶层对象。但是Node.js 模块中`this`返回的是当前模块ES6 模块中`this`返回的是`undefined`
- 函数里面的`this`,如果函数不是作为对象的方法运行,而是单纯作为函数运行,`this`会指向顶层对象。但是,严格模式下,这时`this`会返回`undefined`
- 不管是严格模式,还是普通模式,`new Function('return this')()`,总是会返回全局对象。但是,如果浏览器用了 CSPContent Security Policy内容安全策略那么`eval``new Function`这些方法都可能无法使用。