Skip to content

Commit b884341

Browse files
authored
Merge pull request ruanyf#701 from favefan/patch-1
word change.
2 parents 83bad90 + e4351e2 commit b884341

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/let.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ ES5 的顶层对象,本身也是一个问题,因为它在各种实现里面
591591

592592
- 全局环境中,`this`会返回顶层对象。但是,Node 模块和 ES6 模块中,`this`返回的是当前模块。
593593
- 函数里面的`this`,如果函数不是作为对象的方法运行,而是单纯作为函数运行,`this`会指向顶层对象。但是,严格模式下,这时`this`会返回`undefined`
594-
- 不管是严格模式,还是普通模式,`new Function('return this')()`,总是会返回全局对象。但是,如果浏览器用了 CSP(Content Security Policy,内容安全政策),那么`eval``new Function`这些方法都可能无法使用。
594+
- 不管是严格模式,还是普通模式,`new Function('return this')()`,总是会返回全局对象。但是,如果浏览器用了 CSP(Content Security Policy,内容安全策略),那么`eval``new Function`这些方法都可能无法使用。
595595

596596
综上所述,很难找到一种方法,可以在所有情况下,都取到顶层对象。下面是两种勉强可以使用的方法。
597597

0 commit comments

Comments
 (0)