From c40612041809fe289aba58aefa170bbe784aba1f Mon Sep 17 00:00:00 2001 From: t7yang Date: Mon, 10 Jan 2022 08:38:07 +0800 Subject: remove name attribute for zh-CN --- .../reference/global_objects/array/concat/index.html | 12 ++++++------ .../global_objects/array/copywithin/index.html | 2 +- .../reference/global_objects/array/fill/index.html | 8 ++++---- .../reference/global_objects/array/find/index.html | 10 +++++----- .../global_objects/array/findindex/index.html | 12 ++++++------ .../reference/global_objects/array/indexof/index.html | 4 ++-- .../reference/global_objects/array/join/index.html | 16 ++++++++-------- .../reference/global_objects/array/keys/index.html | 10 +++++----- .../global_objects/array/lastindexof/index.html | 18 +++++++++--------- .../reference/global_objects/array/length/index.html | 8 ++++---- .../reference/global_objects/array/map/index.html | 16 ++++++++-------- .../reference/global_objects/array/of/index.html | 6 +++--- .../reference/global_objects/array/pop/index.html | 8 ++++---- .../reference/global_objects/array/push/index.html | 2 +- .../reference/global_objects/array/reverse/index.html | 2 +- .../reference/global_objects/array/slice/index.html | 6 +++--- .../reference/global_objects/array/some/index.html | 14 +++++++------- .../reference/global_objects/array/sort/index.html | 16 ++++++++-------- .../global_objects/array/tolocalestring/index.html | 4 ++-- .../reference/global_objects/array/tosource/index.html | 14 +++++++------- .../reference/global_objects/array/tostring/index.html | 6 +++--- .../reference/global_objects/array/unshift/index.html | 6 +++--- 22 files changed, 100 insertions(+), 100 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/array') diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html index b0960c35d0..dbd74c0909 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat
var new_array = old_array.concat(value1[, value2[, ...[, valueN]]])
-

参数

+

参数

valueN{{optional_inline}}
@@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat

新的 {{jsxref("Array")}} 实例。

-

描述

+

描述

concat方法创建一个新的数组,它由被调用的对象中的元素组成,每个参数的顺序依次是该参数的元素(如果参数是数组)或参数本身(如果参数不是数组)。它不会递归到嵌套数组参数中。

@@ -47,9 +47,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat

注意:数组/值在连接时保持不变。此外,对于新数组的任何操作(仅当元素不是对象引用时)都不会对原始数组产生影响,反之亦然。

-

示例

+

示例

-

连接两个数组

+

连接两个数组

以下代码将两个数组合并为一个新数组:

@@ -59,7 +59,7 @@ var numeric = [1, 2, 3]; alpha.concat(numeric); // result in ['a', 'b', 'c', 1, 2, 3] -

连接三个数组

+

连接三个数组

以下代码将三个数组合并为一个新数组:

@@ -72,7 +72,7 @@ var nums = num1.concat(num2, num3); console.log(nums); // results in [1, 2, 3, 4, 5, 6, 7, 8, 9] -

将值连接到数组

+

将值连接到数组

以下代码将三个值连接到数组:

diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html index b19fa2fc56..63436145d7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html @@ -23,7 +23,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/copyWithin
arr.copyWithin(target[, start[, end]])
 
-

参数

+

参数

target
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html index 07c1c104b5..0b7cdccee9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/fill

{{EmbedInteractiveExample("pages/js/array-fill.html")}}

-

语法

+

语法

arr.fill(value[start[end]])
-

参数

+

参数

value
@@ -34,7 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/fill

修改后的数组。

-

描述

+

描述

fill 方法接受三个参数 value, start 以及 endstartend 参数是可选的, 其默认值分别为 0 和 this 对象的 length 属性值。

@@ -145,7 +145,7 @@ arr[0].hi = "hi"; // [{ hi: "hi" }, { hi: "hi" }, { hi: "hi" }] -

相关

+

相关

  • {{jsxref("Array")}}
  • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html index 425901f14d..ee5ad032da 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html @@ -19,11 +19,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/find

    如果你需要找到一个元素的位置或者一个元素是否存在于数组中,使用{{jsxref("Array.prototype.indexOf()")}} 或 {{jsxref("Array.prototype.includes()")}}。

    -

    语法

    +

    语法

    arr.find(callback[, thisArg])
    -

    参数

    +

    参数

    callback
    @@ -45,7 +45,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/find

    数组中第一个满足所提供测试函数的元素的值,否则返回 {{jsxref("undefined")}}。

    -

    描述

    +

    描述

    find方法对数组中的每一项元素执行一次 callback 函数,直至有一个 callback 返回 true。当找到了这样一个元素后,该方法会立即返回这个元素的值,否则返回 {{jsxref("undefined")}}。注意 callback 函数会为数组中的每个索引调用即从 0 length - 1,而不仅仅是那些被赋值的索引,这意味着对于稀疏数组来说,该方法的效率要低于那些只遍历有值的索引的方法。

    @@ -114,7 +114,7 @@ a.find(function(value, index) { console.log('Visited index ' + index + ' with value ' + value); }); -

    Polyfill

    +

    Polyfill

    本方法在ECMAScript 6规范中被加入,可能不存在于某些实现中。你可以通过以下代码来补充 Array.prototype.find()

    @@ -189,7 +189,7 @@ if (!Array.prototype.find) {

    {{Compat("javascript.builtins.Array.find")}}

    -

    相关链接

    +

    相关链接

    • {{jsxref("Array.prototype.findIndex()")}} – find and return an index
    • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html index ecde3c0f25..39faf1fdf3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html @@ -18,11 +18,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex

      另请参见  {{jsxref("Array.find", "find()")}} 方法,它返回数组中找到的元素的,而不是其索引。

      -

      语法

      +

      语法

      arr.findIndex(callback[, thisArg])
      -

      参数

      +

      参数

      callback
      @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex

          数组中通过提供测试函数的第一个元素的索引。否则,返回-1

      -

      描述

      +

      描述

      findIndex方法对数组中的每个数组索引0..length-1(包括)执行一次callback函数,直到找到一个callback函数返回真实值(强制为true)的值。如果找到这样的元素,findIndex会立即返回该元素的索引。如果回调从不返回真值,或者数组的length为0,则findIndex返回-1。 与某些其他数组方法(如Array#some)不同,在稀疏数组中,即使对于数组中不存在的条目的索引也会调用回调函数。

      @@ -56,9 +56,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex

      在第一次调用callback函数时会确定元素的索引范围,因此在findIndex方法开始执行之后添加到数组的新元素将不会被callback函数访问到。如果数组中一个尚未被callback函数访问到的元素的值被callback函数所改变,那么当callback函数访问到它时,它的值是将是根据它在数组中的索引所访问到的当前值。被删除的元素仍然会被访问到。

      -

      示例

      +

      示例

      -

      查找数组中首个质数元素的索引

      +

      查找数组中首个质数元素的索引

      以下示例查找数组中素数的元素的索引(如果不存在素数,则返回-1)。

      @@ -153,7 +153,7 @@ if (!Array.prototype.findIndex) {

      {{Compat("javascript.builtins.Array.findIndex")}}

      -

      相关链接

      +

      相关链接

      • {{jsxref("Array.prototype.find()")}}
      • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html index c470a8b265..a4ef7ead3b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/indexOf

        注意:对于String方法,请参阅 {{jsxref("String.prototype.indexOf()")}}。

        -

        语法

        +

        语法

        arr.indexOf(searchElement[, fromIndex])
        @@ -189,7 +189,7 @@ if (!Array.prototype.indexOf) {

        {{Compat("javascript.builtins.Array.indexOf")}}

        -

        相关链接

        +

        相关链接

        • {{jsxref("Array.prototype.lastIndexOf()")}}
        • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html index c40b87ebed..b4c06b6acb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html @@ -14,11 +14,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join
          {{EmbedInteractiveExample("pages/js/array-join.html")}}
          -

          语法

          +

          语法

          arr.join([separator])
          -

          参数

          +

          参数

          separator {{optional_inline}}
          @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join
          一个所有数组元素连接的字符串。如果 arr.length 为0,则返回空字符串。
          -

          描述

          +

          描述

          所有的数组元素被转换成字符串,再用一个分隔符将这些字符串连接起来。

          @@ -37,9 +37,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join

          如果一个元素为 undefined 或 null,它会被转换为空字符串。

          -

          示例

          +

          示例

          -

          使用四种不同的分隔符连接数组元素

          +

          使用四种不同的分隔符连接数组元素

          下例首先创建了一个数组 a,包含有三个元素,然后用四种不同的分隔符连接所有数组元素。首先是默认的分隔符逗号,然后是一个逗号加空格,接下来是一个加号前后加空格,最后是一个空字符串。

          @@ -60,7 +60,7 @@ var myVar4 = a.join(''); // myVar4的值变为"WindRainFire" } f(1, 'a', true); -

          规范

          +

          规范

          @@ -92,7 +92,7 @@ f(1, 'a', true);
          -

          浏览器兼容性

          +

          浏览器兼容性

          @@ -102,7 +102,7 @@ f(1, 'a', true);
          -

          相关链接

          +

          相关链接

          • {{jsxref("String.prototype.split()")}}
          • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html index 6da9228ed2..b8e10fdada 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/keys
            {{EmbedInteractiveExample("pages/js/array-keys.html")}}
            -

            语法

            +

            语法

            arr.keys()
             
            @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/keys

            一个新的 {{jsxref("Array")}} 迭代器对象。

            -

            示例

            +

            示例

            索引迭代器会包含那些没有对应元素的索引

            @@ -36,7 +36,7 @@ console.log(sparseKeys); // ['0', '2'] console.log(denseKeys); // [0, 1, 2] -

            规范

            +

            规范

            @@ -58,7 +58,7 @@ console.log(denseKeys); // [0, 1, 2]
            -

            浏览器兼容性

            +

            浏览器兼容性

            @@ -68,7 +68,7 @@ console.log(denseKeys); // [0, 1, 2]
            -

            相关链接

            +

            相关链接

            • {{jsxref("Array.prototype.values()")}}
            • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html index 51cf89a71f..8d3c63aab0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html @@ -5,17 +5,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf ---
              {{JSRef("Global_Objects", "Array")}}
              -

              概述

              +

              概述

              lastIndexOf() 方法返回指定元素(也即有效的 JavaScript 值或变量)在数组中的最后一个的索引,如果不存在则返回 -1。从数组的后面向前查找,从 fromIndex 处开始。

              {{EmbedInteractiveExample("pages/js/array-lastindexof.html")}}
              -

              语法

              +

              语法

              arr.lastIndexOf(searchElement[, fromIndex])
              -

              参数

              +

              参数

              searchElement
              @@ -29,13 +29,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
              -

              描述

              +

              描述

              lastIndexOf 使用严格相等(strict equality,即 ===)比较 searchElement 和数组中的元素。

              -

              示例

              +

              示例

              -

              例子:使用 lastIndexOf

              +

              例子:使用 lastIndexOf

              下例使用 lastIndexOf 定位数组中的值。

              @@ -54,7 +54,7 @@ index = array.lastIndexOf(2, -1); // index is 3 -

              例子:查找所有元素

              +

              例子:查找所有元素

              下例使用 lastIndexOf 查找到一个元素在数组中所有的索引(下标),并使用 {{jsxref("Array.push", "push")}} 将所有添加到另一个数组中。

              @@ -80,7 +80,7 @@ console.log(indices); idx > 0时,才进入lastIndexOf由后往前移一位进行倒查找;如果idx == 0则直接设置idx = -1,循环while (idx != -1)就结束了。
               

              -

              兼容旧环境(Polyfill)

              +

              兼容旧环境(Polyfill)

              lastIndexOf 在 ECMA-262 标准第 5 版被添加。因此它在不兼容该标准的浏览器中可能不被支持。你可以把下面代码添加到脚本中来使那些没有实现该方法的实现环境支持该方法。该算法是被 ECMA-262 第 5 版指定的。假定 {{jsxref("Global_Objects/Object", "Object")}}、{{jsxref("Global_Objects/TypeError", "TypeError")}}、{{jsxref("Global_Objects/Number", "Number")}}、{{jsxref("Math.floor")}}、{{jsxref("Math.abs")}},以及 {{jsxref("Math.min")}} 拥有其初始值。

              @@ -168,7 +168,7 @@ console.log(indices);

              {{Compat("javascript.builtins.Array.lastIndexOf")}}

              -

              相关链接

              +

              相关链接

              • {{jsxref("Array.prototype.indexOf()")}}
              • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html index de5862921d..dfab0b020f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/length
                {{EmbedInteractiveExample("pages/js/array-length.html")}}
                -

                描述

                +

                描述

                length 属性的值是一个 0 到 232-1 的整数。

                @@ -76,9 +76,9 @@ function printEntries(arr) {
              • Enumerable :如果设置为 true ,属性可以通过迭代器forfor...in进行迭代。
              -

              示例 

              +

              示例 

              -

              遍历数组

              +

              遍历数组

              下面的例子中,通过数组下标遍历数组元素,并把每个元素的值修改为原值的2倍。

              @@ -89,7 +89,7 @@ for (var i = 0; i < length; i++) { } // 遍历后的结果 [2, 4, 6, 8, 10] -

              截断数组

              +

              截断数组

              下面的例子中,如果数组长度大于 3,则把该数组的长度截断为 3 。

              diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html index 15e10d0329..dc8241fd26 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html @@ -18,13 +18,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map -

              语法

              +

              语法

              var new_array = arr.map(function callback(currentValue[, index[, array]]) {
                // Return element for new_array 
               }[, thisArg])
              -

              参数

              +

              参数

              callback
              @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map

              一个由原数组每个元素执行回调函数的结果组成的新数组。

              -

              描述

              +

              描述

              map 方法会给原数组中的每个元素都按顺序调用一次  callback 函数。callback 每次执行后的返回值(包括 {{jsxref("undefined")}})组合起来形成一个新数组。 callback 函数只会在有值的索引上被调用;那些从来没被赋过值或者使用 delete 删除的索引则不会被调用。

              @@ -62,9 +62,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map

              根据规范中定义的算法,如果被map调用的数组是离散的,新数组将也是离散的保持相同的索引为空。

              -

              示例

              +

              示例

              -

              求数组中每个元素的平方根

              +

              求数组中每个元素的平方根

              下面的代码创建了一个新数组,值为原数组中对应数字的平方根。

              @@ -94,7 +94,7 @@ var reformattedArray = kvArray.map(function(obj) { // {key: 3, value: 30}] -

              使用一个包含一个参数的函数来mapping(构建)一个数字数组

              +

              使用一个包含一个参数的函数来mapping(构建)一个数字数组

              下面的代码表示了当函数需要一个参数时map的工作方式。当map循环遍历原始数组时,这个参数会自动被分配成数组中对应的每个元素。

              @@ -106,7 +106,7 @@ var doubles = numbers.map(function(num) { // doubles数组的值为: [2, 8, 18] // numbers数组未被修改: [1, 4, 9] -

              一般的map 方法

              +

              一般的map 方法

              下面的例子演示如何在一个 {{jsxref("String")}}  上使用 map 方法获取字符串中每个字符所对应的 ASCII 码组成的数组:

              @@ -334,7 +334,7 @@ if (!Array.prototype.map) {

              {{Compat("javascript.builtins.Array.map")}}

              -

              相关链接

              +

              相关链接

              • {{jsxref("Array.prototype.forEach()")}}
              • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html index 9013ce9446..8c12486fe2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html @@ -24,11 +24,11 @@ Array(7); // [ , , , , , , ] Array(1, 2, 3); // [1, 2, 3] -

                语法

                +

                语法

                Array.of(element0[, element1[, ...[, elementN]]])
                -

                参数

                +

                参数

                elementN
                @@ -50,7 +50,7 @@ Array.of(1, 2, 3); // [1, 2, 3] Array.of(undefined); // [undefined] -

                兼容旧环境

                +

                兼容旧环境

                如果原生不支持的话,在其他代码之前执行以下代码会创建 Array.of() 。

                diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html index 3e6caa6795..9ee915c4f4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html @@ -17,7 +17,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop -

                语法

                +

                语法

                arr.pop()
                @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop

                从数组中删除的元素(当数组为空时返回{{jsxref("undefined")}})。

                -

                描述

                +

                描述

                pop 方法从一个数组中删除并返回最后一个元素。

                @@ -33,9 +33,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop

                如果你在一个空数组上调用 pop(),它返回  {{jsxref("undefined")}}。

                -

                示例

                +

                示例

                -

                例子: 删除掉数组的最后一个元素

                +

                例子: 删除掉数组的最后一个元素

                下面的代码首先创建了一个拥有四个元素的数组 myFish,然后删除掉它的最后一个元素。

                diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html index 032e985d22..fd1154f7c6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/push

                当调用该方法时,新的 {{jsxref("Array.length", "length")}} 属性值将被返回。

                -

                描述

                +

                描述

                push方法将值追加到数组中。

                diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html index b408aa046f..2ec4feba05 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html @@ -132,7 +132,7 @@ console.log(a); // {0: 3, 1: 2, 2: 1, length: 3} -

                相关链接

                +

                相关链接

                • {{jsxref("Array.prototype.join()")}}
                • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html index d62b834d40..74703cbe04 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html @@ -57,7 +57,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/slice

                  如果向两个数组任一中添加了新元素,则另一个不会受到影响。

                  -

                  示例

                  +

                  示例

                  返回现有数组的一部分

                  @@ -108,7 +108,7 @@ The new color of my Honda is purple newCar[0].color = purple -

                  类数组(Array-like)对象

                  +

                  类数组(Array-like)对象

                  slice 方法可以用来将一个类数组(Array-like)对象/集合转换成一个新数组。你只需将该方法绑定到这个对象上。 一个函数中的  {{jsxref("Functions/arguments", "arguments")}} 就是一个类数组对象的例子。

                  @@ -242,7 +242,7 @@ var list1 = list(1, 2, 3); // [1, 2, 3]

                  {{Compat("javascript.builtins.Array.slice")}}

                  -

                  相关链接

                  +

                  相关链接

                  • {{jsxref("Array.prototype.splice()")}}
                  • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html index 8c5aabec0f..a0f5695dfb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html @@ -20,11 +20,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some
                    {{EmbedInteractiveExample("pages/js/array-some.html")}}
                    -

                    语法

                    +

                    语法

                    arr.some(callback(element[, index[, array]])[, thisArg])
                    -

                    参数

                    +

                    参数

                    callback
                    @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some

                    数组中有至少一个元素通过回调函数的测试就会返回true;所有元素都没有通过回调函数的测试返回值才会为false。

                    -

                    描述

                    +

                    描述

                    some() 为数组中的每一个元素执行一次 callback 函数,直到找到一个使得 callback 返回一个“真值”(即可转换为布尔值 true 的值)。如果找到了这样一个值,some() 将会立即返回 true。否则,some() 返回 falsecallback 只会在那些”有值“的索引上被调用,不会在那些被删除或从来未被赋值的索引上调用。

                    @@ -58,9 +58,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some

                    some() 遍历的元素的范围在第一次调用 callback. 前就已经确定了。在调用 some() 后被添加到数组中的值不会被 callback 访问到。如果数组中存在且还未被访问到的元素被 callback 改变了,则其传递给 callback 的值是 some() 访问到它那一刻的值。已经被删除的元素不会被访问到。

                    -

                    示例

                    +

                    示例

                    -

                    测试数组元素的值

                    +

                    测试数组元素的值

                    下面的例子检测在数组中是否有元素大于 10。

                    @@ -127,7 +127,7 @@ getBoolean(1); // true getBoolean('true'); // true -

                    Polyfill

                    +

                    Polyfill

                    在第 5 版时,some() 被添加进 ECMA-262 标准;这样导致某些实现环境可能不支持它。你可以把下面的代码插入到脚本的开头来解决此问题,从而允许在那些没有原生支持它的实现环境中使用它。该算法是 ECMA-262 第 5 版中指定的算法,假定 Object 和 TypeError 拥有他们的初始值,且 fun.call 等价于 {{jsxref("Function.prototype.call")}}

                    @@ -196,7 +196,7 @@ if (!Array.prototype.some) {

                    {{Compat("javascript.builtins.Array.some")}}

                    -

                    相关链接

                    +

                    相关链接

                    • {{jsxref("Array.prototype.find()")}}
                    • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html index e4140bde3b..49a4339d87 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html @@ -42,7 +42,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/sort

                      排序后的数组。请注意,数组已原地排序,并且不进行复制。

                      -

                      描述

                      +

                      描述

                      如果没有指明 compareFunction ,那么元素会按照转换为的字符串的诸个字符的Unicode位点进行排序。例如 "Banana" 会被排列到 "cherry" 之前。当数字按由小到大排序时,9 出现在 80 之前,但因为(没有指明 compareFunction),比较的数字会先被转换为字符串,所以在Unicode顺序上 "80" 要比 "9" 要靠前。

                      @@ -129,9 +129,9 @@ items.sort(function(a, b) { return 0; }); -

                      示例

                      +

                      示例

                      -

                      创建、显示及排序数组

                      +

                      创建、显示及排序数组

                      下述示例创建了四个数组,并展示原数组。之后对数组进行排序。对比了数字数组分别指定与不指定比较函数的结果。

                      @@ -179,7 +179,7 @@ Sorted without a compare function: 1,200,40,5,700,80,9 Sorted with compareNumbers: 1,5,9,40,80,200,700 -

                      对非 ASCII 字符排序

                      +

                      对非 ASCII 字符排序

                      当排序非 ASCII 字符的字符串(如包含类似 e, é, è, a, ä 等字符的字符串)。一些非英语语言的字符串需要使用 {{jsxref("String.localeCompare")}}。这个函数可以将函数排序到正确的顺序。

                      @@ -191,7 +191,7 @@ items.sort(function (a, b) { // items is ['adieu', 'café', 'cliché', 'communiqué', 'premier', 'réservé'] -

                      使用映射改善排序

                      +

                      使用映射改善排序

                      compareFunction 可能需要对元素做多次映射以实现排序,尤其当 compareFunction 较为复杂,且元素较多的时候,某些 compareFunction 可能会导致很高的负载。使用 map 辅助排序将会是一个好主意。基本思想是首先将数组中的每个元素比较的实际值取出来,排序后再将数组恢复。

                      @@ -253,7 +253,7 @@ var result = mapped.map(function(el){ ]; -

                      规范

                      +

                      规范

                      @@ -285,7 +285,7 @@ var result = mapped.map(function(el){
                      -

                      浏览器兼容性

                      +

                      浏览器兼容性

                      @@ -295,7 +295,7 @@ var result = mapped.map(function(el){
                      -

                      参考

                      +

                      参考

                      • {{jsxref("Array.prototype.reverse()")}}
                      • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html index 729e537627..b893cd7f87 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toLocaleString
                        {{EmbedInteractiveExample("pages/js/array-tolocalestring.html")}}
                        -

                        语法

                        +

                        语法

                        arr.toLocaleString([locales[,options]]);
                        @@ -166,7 +166,7 @@ if (!Array.prototype.toLocaleString) {

                        {{Compat("javascript.builtins.Array.toLocaleString")}}

                        -

                        参见

                        +

                        参见

                        • {{jsxref("Array.prototype.toString()")}}
                        • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html index 7ff8cff304..a5371b0a9f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html @@ -5,25 +5,25 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toSource ---

                          {{JSRef("Global_Objects", "Array")}}{{Non-standard_header}}

                          -

                          概述

                          +

                          概述

                          返回一个字符串,代表该数组的源代码.

                          -

                          语法

                          +

                          语法

                          array.toSource()
                          -

                          参数

                          +

                          参数

                          -

                          描述

                          +

                          描述

                          在调试时,你可以使用toSource方法来查看一个数组的内容.

                          -

                          例子

                          +

                          例子

                          -

                          例子: 查看数组的源码

                          +

                          例子: 查看数组的源码

                          var alpha = new Array("a", "b", "c");
                           
                          @@ -33,7 +33,7 @@ alpha.toSource();   //返回["a", "b", "c"]

                          {{Compat("javascript.builtins.Array.toSource")}}

                          -

                          相关链接

                          +

                          相关链接

                          • Array.toString
                          • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html index 2378e078f8..3c41f1dbc4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html @@ -13,12 +13,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toString
                            {{EmbedInteractiveExample("pages/js/array-tostring.html")}}
                            -

                            语法

                            +

                            语法

                            arr.toString()
                             
                            -

                            返回值

                            +

                            返回值

                            一个表示指定的数组及其元素的字符串。

                            @@ -72,7 +72,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toString

                            {{Compat("javascript.builtins.Array.toString")}}

                            -

                            相关链接

                            +

                            相关链接

                            • {{jsxref("Array.prototype.join()")}}
                            • diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html index b05c74e64f..e6e2a8b693 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html @@ -17,12 +17,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/unshift
                              {{EmbedInteractiveExample("pages/js/array-unshift.html")}}
                              -

                              语法

                              +

                              语法

                              arr.unshift(element1, ..., elementN)
                               
                              -

                              参数列表

                              +

                              参数列表

                              elementN
                              @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/unshift
                              -

                              描述

                              +

                              描述

                              unshift 方法会在调用它的类数组对象的开始位置插入给定的参数。

                              -- cgit v1.2.3-54-g00ecf