From a02f4b2f60c81e09b318a090e5c9c2d2d641c878 Mon Sep 17 00:00:00 2001 From: t7yang Date: Sat, 17 Jul 2021 16:10:02 +0800 Subject: replace wiki links in zh-CN --- files/zh-cn/web/javascript/reference/classes/index.html | 2 +- .../web/javascript/reference/functions/arguments/index.html | 4 ++-- .../javascript/reference/global_objects/bigint/index.html | 2 +- .../reference/global_objects/bigint64array/index.html | 4 ++-- .../javascript/reference/global_objects/boolean/index.html | 4 ++-- .../reference/global_objects/encodeuricomponent/index.html | 2 +- .../reference/global_objects/globalthis/index.html | 2 +- .../reference/global_objects/math/random/index.html | 2 +- .../reference/global_objects/object/assign/index.html | 2 +- .../reference/global_objects/promise/allsettled/index.html | 6 +++--- .../javascript/reference/global_objects/reflect/index.html | 4 ++-- .../javascript/reference/global_objects/regexp/index.html | 2 +- .../web/javascript/reference/global_objects/set/index.html | 2 +- .../web/javascript/reference/operators/inequality/index.html | 12 ++++++------ .../reference/operators/optional_chaining/index.html | 2 +- .../zh-cn/web/javascript/reference/operators/this/index.html | 2 +- .../web/javascript/reference/statements/import/index.html | 2 +- 17 files changed, 28 insertions(+), 28 deletions(-) (limited to 'files/zh-cn/web/javascript/reference') diff --git a/files/zh-cn/web/javascript/reference/classes/index.html b/files/zh-cn/web/javascript/reference/classes/index.html index 5c91d8d219..89045127bf 100644 --- a/files/zh-cn/web/javascript/reference/classes/index.html +++ b/files/zh-cn/web/javascript/reference/classes/index.html @@ -67,7 +67,7 @@ console.log(Rectangle.name); // 输出: "Rectangle2"
-

注意: 类表达式也同样受到类声明部分中提到的类型提升的限制。

+

注意: 类表达式也同样受到类声明部分中提到的类型提升的限制。

类体和方法定义

diff --git a/files/zh-cn/web/javascript/reference/functions/arguments/index.html b/files/zh-cn/web/javascript/reference/functions/arguments/index.html index 22ec42ac8f..937a5f7e7c 100644 --- a/files/zh-cn/web/javascript/reference/functions/arguments/index.html +++ b/files/zh-cn/web/javascript/reference/functions/arguments/index.html @@ -26,11 +26,11 @@ translation_of: Web/JavaScript/Reference/Functions/arguments

描述

-

Note: If you're writing ES6 compatible code, then rest parameters should be preferred.

+

Note: If you're writing ES6 compatible code, then rest parameters should be preferred.

-

Note: “Array-like” means that arguments has a {{jsxref("Functions/arguments/length", "length")}} property and properties indexed from zero, but it doesn't have {{JSxRef("Array")}}'s built-in methods like {{jsxref("Array.forEach", "forEach()")}} and {{jsxref("Array.map", "map()")}}. See §Description for details.

+

Note: “Array-like” means that arguments has a {{jsxref("Functions/arguments/length", "length")}} property and properties indexed from zero, but it doesn't have {{JSxRef("Array")}}'s built-in methods like {{jsxref("Array.forEach", "forEach()")}} and {{jsxref("Array.map", "map()")}}. See §Description for details.

arguments对象是所有(非箭头)函数中都可用的局部变量。你可以使用arguments对象在函数中引用函数的参数。此对象包含传递给函数的每个参数,第一个参数在索引0处。例如,如果一个函数传递了三个参数,你可以以如下方式引用他们:

diff --git a/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html b/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html index 1ef191efc0..225cda75d6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html @@ -161,7 +161,7 @@ Boolean(12n)

构造器

-
BigInt()
+
BigInt()
创建{{jsxref("BigInt")}} 对象。
diff --git a/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html b/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html index c7f47fef77..31ac75a13e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/BigInt64Array

构造函数

-

BigInt64Array()

+

BigInt64Array()

     添加一个新的BigInt64Array对象。

@@ -167,7 +167,7 @@ var bigint64 = new BigInt64Array(iterable);

参考

diff --git a/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html b/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html index 9b0ba4ae06..a236f20273 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html @@ -51,13 +51,13 @@ var s = new Boolean(myString); // true

最后,不要在应该使用基本类型布尔值的地方使用 Boolean 对象。

-

注意:当将非标准属性document.all用作此构造函数的参数时,结果是值为false的布尔对象。 此属性是旧属性,是非标准属性,不应使用。

+

注意:当将非标准属性document.all用作此构造函数的参数时,结果是值为false的布尔对象。 此属性是旧属性,是非标准属性,不应使用。

构造器

-
Boolean()
+
Boolean()
创建一个新的Boolean 对象。
diff --git a/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html b/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html index d80cd457c9..be7f03a446 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/encodeuricomponent/index.html @@ -9,7 +9,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/encodeURIComponent ---
{{jsSidebar("Objects")}}
-

encodeURIComponent()函数通过将一个,两个,三个或四个表示字符的UTF-8编码的转义序列替换某些字符的每个实例来编码 URI (对于由两个“代理”字符组成的字符而言,将仅是四个转义序列) 。

+

encodeURIComponent()函数通过将一个,两个,三个或四个表示字符的UTF-8编码的转义序列替换某些字符的每个实例来编码 URI (对于由两个“代理”字符组成的字符而言,将仅是四个转义序列) 。

{{EmbedInteractiveExample("pages/js/globalprops-encodeuricomponent.html","shorter")}}

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 20b6dba280..7260d8cbfa 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

在以前,从不同的 JavaScript 环境中获取全局对象需要不同的语句。在 Web 中,可以通过 windowself 或者 frames 取到全局对象,但是在 Web Workers 中,只有 self 可以。在 Node.js 中,它们都无法获取,必须使用 global

-

在松散模式下,可以在函数中返回 this 来获取全局对象,但是在严格模式和模块环境下,this 会返回 undefined。 You can also use Function('return this')(), but environments that disable {{jsxref("eval", "eval()")}}, like CSP in browsers, prevent use of {{jsxref("Function")}} in this way.

+

在松散模式下,可以在函数中返回 this 来获取全局对象,但是在严格模式和模块环境下,this 会返回 undefined。 You can also use Function('return this')(), but environments that disable {{jsxref("eval", "eval()")}}, like CSP in browsers, prevent use of {{jsxref("Function")}} in this way.

globalThis 提供了一个标准的方式来获取不同环境下的全局 this  对象(也就是全局对象自身)。不像 window 或者 self 这些属性,它确保可以在有无窗口的各种环境下正常工作。所以,你可以安心的使用 globalThis,不必担心它的运行环境。为便于记忆,你只需要记住,全局作用域中的 this 就是 globalThis

diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html index ea760c65f6..efc11b6894 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html @@ -90,5 +90,5 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random

相关链接

diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html index abe605e620..1e1080be00 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html @@ -51,7 +51,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign

Polyfill

-

这个 polyfill 不支持 symbol 属性, 由于 ES5 中本来就不存在 symbols :

+

这个 polyfill 不支持 symbol 属性, 由于 ES5 中本来就不存在 symbols :

if (typeof Object.assign !== 'function') {
   // Must be writable: true, enumerable: false, configurable: true
diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/allsettled/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/allsettled/index.html
index 919da6e0b8..d552f10680 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/promise/allsettled/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/promise/allsettled/index.html
@@ -59,11 +59,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/allSettled
 
 
diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/index.html
index b35fe77d5c..4b430c4772 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/reflect/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/index.html
@@ -10,13 +10,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Reflect
 ---
 
{{JSRef}}
-

Reflect 是一个内置的对象,它提供拦截 JavaScript 操作的方法。这些方法与proxy handlers的方法相同。Reflect不是一个函数对象,因此它是不可构造的。

+

Reflect 是一个内置的对象,它提供拦截 JavaScript 操作的方法。这些方法与proxy handlers的方法相同。Reflect不是一个函数对象,因此它是不可构造的。

描述

与大多数全局对象不同Reflect并非一个构造函数,所以不能通过new运算符对其进行调用,或者将Reflect对象作为一个函数来调用。Reflect的所有属性和方法都是静态的(就像{{jsxref("Math")}}对象)。

-

Reflect 对象提供了以下静态方法,这些方法与proxy handler methods的命名相同.

+

Reflect 对象提供了以下静态方法,这些方法与proxy handler methods的命名相同.

其中的一些方法与 {{jsxref("Object")}}相同, 尽管二者之间存在 某些细微上的差别 .

diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html index 27da890c46..2a1e6ffcf5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html @@ -200,7 +200,7 @@ console.log(regex.lastIndex); // prints "15" // and so on
-

Unicode属性转义特性引入了一种解决方案,它允许使用像\p{scx=Cyrl}这样简单的语句。这里有一个外部资源,用来获取 Unicode 中的不同区块范围:Regexp-unicode-block

+

Unicode属性转义特性引入了一种解决方案,它允许使用像\p{scx=Cyrl}这样简单的语句。这里有一个外部资源,用来获取 Unicode 中的不同区块范围:Regexp-unicode-block

从 URL 中提取子域名

diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/index.html index 49ede8bf54..3e8c53dc64 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/index.html @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set

Constructor

-
Set()
+
Set()
创建一个新的Set对象。
diff --git a/files/zh-cn/web/javascript/reference/operators/inequality/index.html b/files/zh-cn/web/javascript/reference/operators/inequality/index.html index 867bda689f..dfa41522d1 100644 --- a/files/zh-cn/web/javascript/reference/operators/inequality/index.html +++ b/files/zh-cn/web/javascript/reference/operators/inequality/index.html @@ -22,19 +22,19 @@ translation_of: Web/JavaScript/Reference/Operators/Inequality

描述

-

不等式运算符检查其操作数是否不相等。这是等于运算符的取反,因此以下两行将始终给出相同的结果: 

+

不等式运算符检查其操作数是否不相等。这是等于运算符的取反,因此以下两行将始终给出相同的结果: 

x != y
 
 !(x == y)
-

有关比较算法的详细信息,请参见等于运算符的页面

+

有关比较算法的详细信息,请参见等于运算符的页面

与等于运算符一样,不等于运算符将尝试转换和比较不同类型的操作数:

3 != "3"; // false
-

为避免这种情况,并要求将不同类型视为不同,请使用严格的不等于运算符:

+

为避免这种情况,并要求将不同类型视为不同,请使用严格的不等于运算符:

3 !== "3"; // true
@@ -94,9 +94,9 @@ object2 != object2 // false

参见

diff --git a/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html b/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html index 2c91f70141..6f639f537a 100644 --- a/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html +++ b/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html @@ -16,7 +16,7 @@ original_slug: Web/JavaScript/Reference/Operators/可选链 ---
{{JSSidebar("Operators")}}
-

可选链操作符( ?. )允许读取位于连接对象链深处的属性的值,而不必明确验证链中的每个引用是否有效。?. 操作符的功能类似于 . 链式操作符,不同之处在于,在引用为空(nullish ) ({{JSxRef("null")}} 或者 {{JSxRef("undefined")}}) 的情况下不会引起错误,该表达式短路返回值是 undefined。与函数调用一起使用时,如果给定的函数不存在,则返回 undefined

+

可选链操作符( ?. )允许读取位于连接对象链深处的属性的值,而不必明确验证链中的每个引用是否有效。?. 操作符的功能类似于 . 链式操作符,不同之处在于,在引用为空(nullish ) ({{JSxRef("null")}} 或者 {{JSxRef("undefined")}}) 的情况下不会引起错误,该表达式短路返回值是 undefined。与函数调用一起使用时,如果给定的函数不存在,则返回 undefined

当尝试访问可能不存在的对象属性时,可选链操作符将会使表达式更短、更简明。在探索一个对象的内容时,如果不能确定哪些属性必定存在,可选链操作符也是很有帮助的。

diff --git a/files/zh-cn/web/javascript/reference/operators/this/index.html b/files/zh-cn/web/javascript/reference/operators/this/index.html index 6ea1eb67c6..a53b49cb60 100644 --- a/files/zh-cn/web/javascript/reference/operators/this/index.html +++ b/files/zh-cn/web/javascript/reference/operators/this/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Operators/this

与其他语言相比,函数的 this 关键字在 JavaScript 中的表现略有不同,此外,在严格模式和非严格模式之间也会有一些差别。

-

在绝大多数情况下,函数的调用方式决定了 this 的值(运行时绑定)。this 不能在执行期间被赋值,并且在每次函数被调用时 this 的值也可能会不同。ES5 引入了 bind 方法来设置函数的 this 值,而不用考虑函数如何被调用的。ES2015 引入了箭头函数,箭头函数不提供自身的 this 绑定(this 的值将保持为闭合词法上下文的值)。

+

在绝大多数情况下,函数的调用方式决定了 this 的值(运行时绑定)。this 不能在执行期间被赋值,并且在每次函数被调用时 this 的值也可能会不同。ES5 引入了 bind 方法来设置函数的 this 值,而不用考虑函数如何被调用的。ES2015 引入了箭头函数,箭头函数不提供自身的 this 绑定(this 的值将保持为闭合词法上下文的值)。

{{EmbedInteractiveExample("pages/js/expressions-this.html")}}

diff --git a/files/zh-cn/web/javascript/reference/statements/import/index.html b/files/zh-cn/web/javascript/reference/statements/import/index.html index fabebc11d1..b7634d9cef 100644 --- a/files/zh-cn/web/javascript/reference/statements/import/index.html +++ b/files/zh-cn/web/javascript/reference/statements/import/index.html @@ -136,7 +136,7 @@ var promise = import("module-name");//这是一个处于第三阶段的提案。
  • 当被导入的模块有副作用(这里说的副作用,可以理解为模块中会直接运行的代码),这些副作用只有在触发了某些条件才被需要时。(原则上来说,模块不能有副作用,但是很多时候,你无法控制你所依赖的模块的内容)
  • -

    请不要滥用动态导入(只有在必要情况下采用)。静态框架能更好的初始化依赖,而且更有利于静态分析工具和tree shaking发挥作用

    +

    请不要滥用动态导入(只有在必要情况下采用)。静态框架能更好的初始化依赖,而且更有利于静态分析工具和tree shaking发挥作用

    关键字import可以像调用函数一样来动态的导入模块。以这种方式调用,将返回一个 promise

    -- cgit v1.2.3-54-g00ecf