From 01b0e12ba27b5069248fd09235e9a7143915ee30 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:02:49 +0800 Subject: remove `notranslate` class in zh-CN --- .../web/javascript/reference/global_objects/globalthis/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/globalthis') 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 e3c5d1b0a2..a4dc9510c1 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 @@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/globalThis

语法

-
globalThis
+
globalThis

描述

@@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/globalThis

globalThis 之前,获取某个全局对象的唯一方式就是 Function('return this')(),但是这在某些情况下会违反 CSP 规则,所以,es6-shim 使用了类似如下的方式:

-
var getGlobal = function () {
+
var getGlobal = function () {
   if (typeof self !== 'undefined') { return self; }
   if (typeof window !== 'undefined') { return window; }
   if (typeof global !== 'undefined') { return global; }
@@ -62,7 +62,7 @@ if (typeof globals.setTimeout !== 'function') {
 
 

但是有了 globalThis 之后,只需要:

-
if (typeof globalThis.setTimeout !== 'function') {
+
if (typeof globalThis.setTimeout !== 'function') {
   //  此环境中没有 setTimeout 方法!
 }
-- cgit v1.2.3-54-g00ecf