aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web
diff options
context:
space:
mode:
authorsooia <plus@outlook.at>2021-12-27 23:18:49 +0800
committerGitHub <noreply@github.com>2021-12-27 23:18:49 +0800
commit2c5efd310db3c6651ab86047f46fd02a491f04d2 (patch)
tree8ee47e8bdc2147d59f970645ad25af597d47e8f5 /files/zh-cn/web
parentffd0e4b552c9dcf3e34a5eb3fb2f3f4391a10746 (diff)
downloadtranslated-content-2c5efd310db3c6651ab86047f46fd02a491f04d2.tar.gz
translated-content-2c5efd310db3c6651ab86047f46fd02a491f04d2.tar.bz2
translated-content-2c5efd310db3c6651ab86047f46fd02a491f04d2.zip
Update Web/JavaScript/Reference/Global_Objects/globalThis, zh-CN (#3338)
* change a sentence which wasn't translated. * fix: revise inappropriate translation
Diffstat (limited to 'files/zh-cn/web')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/globalthis/index.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/globalthis/index.html b/files/zh-cn/web/javascript/reference/global_objects/globalthis/index.html
index 19d0fc9426..e9c96e8656 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/globalthis/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/globalthis/index.html
@@ -30,7 +30,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/globalThis
<p>在以前,从不同的 JavaScript 环境中获取全局对象需要不同的语句。在 Web 中,可以通过 <code>window</code>、<code>self</code> 或者 <code>frames</code> 取到全局对象,但是在 <a href="/zh-CN/docs/Web/API/Worker">Web Workers</a> 中,只有 <code>self</code> 可以。在 Node.js 中,它们都无法获取,必须使用 <code>global</code>。</p>
-<p>在松散模式下,可以在函数中返回 <code>this</code> 来获取全局对象,但是在严格模式和模块环境下,<code>this</code> 会返回 <code>undefined</code>。 You can also use <code>Function('return this')()</code>, but environments that disable {{jsxref("eval", "eval()")}}, like <a href="/zh-CN/docs/Glossary/CSP">CSP</a> in browsers, prevent use of {{jsxref("Function")}} in this way.</p>
+<p>在松散模式下,可以在函数中返回 <code>this</code> 来获取全局对象,但是在严格模式和模块环境下,<code>this</code> 会返回 <code>undefined</code>。你也可以使用 <code>Function('return this')()</code>,但那些禁用{{jsxref("eval", "eval()")}}的环境,如在浏览器中的<a href="/zh-CN/docs/Glossary/CSP">CSP</a>,不允许这样使用{{jsxref("Function")}}。</p>
<p><code>globalThis</code> 提供了一个标准的方式来获取不同环境下的全局 <code>this</code>  对象(也就是全局对象自身)。不像 <code>window</code> 或者 <code>self</code> 这些属性,它确保可以在有无窗口的各种环境下正常工作。所以,你可以安心的使用 <code>globalThis</code>,不必担心它的运行环境。为便于记忆,你只需要记住,全局作用域中的 <code>this</code> 就是 <code>globalThis</code>。</p>