aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/array
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/array')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/every/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html10
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/index.md6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/join/index.html12
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/length/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html6
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html30
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html4
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/some/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html2
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/values/index.html8
15 files changed, 49 insertions, 49 deletions
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 dbd74c0909..b612dc454f 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
@@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat
</ul>
<div class="note">
-<p><strong>注意:</strong>数组/值在连接时保持不变。此外,对于新数组的任何操作(仅当元素不是对象引用时)都不会对原始数组产生影响,反之亦然。</p>
+<p><strong>备注:</strong>数组/值在连接时保持不变。此外,对于新数组的任何操作(仅当元素不是对象引用时)都不会对原始数组产生影响,反之亦然。</p>
</div>
<h2 id="Examples">示例</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html
index 38d4388b52..ae369c0559 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html
@@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/every
<p><code><strong>every()</strong></code> 方法测试一个数组内的所有元素是否都能通过某个指定函数的测试。它返回一个布尔值。</p>
<div class="note">
-<p><strong>注意</strong>:若收到一个空数组,此方法在一切情况下都会返回 <code>true</code>。</p>
+<p><strong>备注:</strong>:若收到一个空数组,此方法在一切情况下都会返回 <code>true</code>。</p>
</div>
<div>{{EmbedInteractiveExample("pages/js/array-every.html")}}</div>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html
index 4f06aff1fc..ec0af471c3 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html
@@ -76,7 +76,7 @@ arr.reduce((acc, val) =&gt; acc.concat(val), []);
// 使用扩展运算符 ...
const flattened = arr =&gt; [].concat(...arr);</code></pre>
-<h3 class="brush: js" id="reduce_concat_isArray_recursivity">reduce + concat + isArray + recursivity</h3>
+<h3 id="reduce_concat_isArray_recursivity">reduce + concat + isArray + recursivity</h3>
<pre class="brush: js">// 使用 reduce、concat 和递归展开无限多层嵌套的数组
var arr1 = [1,2,3,[1,2,3,4, [2,3,4]]];
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html
index 6f93bd4513..1c9a181656 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html
@@ -65,7 +65,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/forEach
<p><code>forEach()</code> 被调用时,不会改变原数组,也就是调用它的数组(尽管 <code><var>callback</var></code> 函数在被调用时可能会改变原数组)。(译注:此处说法可能不够明确,具体可参考EMCA语言规范:'<code>forEach</code> does not directly mutate the object on which it is called but the object may be mutated by the calls to <code><var>callbackfn</var></code>.',即 <code>forEach</code> 不会直接改变调用它的对象,但是那个对象可能会被 <code><var>callback</var></code> 函数改变。)</p>
<div class="note">
-<p><strong>注意:</strong> 除了抛出异常以外,没有办法中止或跳出 <code>forEach()</code> 循环。如果你需要中止或跳出循环,<code>forEach()</code> 方法不是应当使用的工具。</p>
+<p><strong>备注:</strong> 除了抛出异常以外,没有办法中止或跳出 <code>forEach()</code> 循环。如果你需要中止或跳出循环,<code>forEach()</code> 方法不是应当使用的工具。</p>
<p>若你需要提前终止循环,你可以使用:</p>
@@ -129,8 +129,8 @@ items.forEach(function(item){
<h3 id="打印出数组的内容">打印出数组的内容</h3>
-<div class="blockIndicator note">
-<p><strong>注意:</strong>为了在控制台中显示数组的内容,你可以使用 <code><a href="/zh-CN/docs/Web/API/Console/table">console.table()</a></code> 来展示经过格式化的数组。下面的例子则是另一种使用 <code>forEach()</code> 的格式化的方法。</p>
+<div class="note">
+<p><strong>备注:</strong>为了在控制台中显示数组的内容,你可以使用 <code><a href="/zh-CN/docs/Web/API/Console/table">console.table()</a></code> 来展示经过格式化的数组。下面的例子则是另一种使用 <code>forEach()</code> 的格式化的方法。</p>
</div>
<p>下面的代码会为每一个数组元素输出一行记录:</p>
@@ -174,7 +174,9 @@ obj.sum;
<p>因为 <code><var>thisArg</var></code> 参数(<code>this</code>)传给了 <code>forEach()</code>,每次调用时,它都被传给 <code><var>callback</var></code> 函数,作为它的 <code>this</code> 值。</p>
<div>
-<div class="note"><strong>注意:</strong>如果使用<a href="/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions">箭头函数表达式</a>来传入函数参数, <code><var>thisArg</var></code> 参数会被忽略,因为箭头函数在词法上绑定了 {{jsxref("Operators/this", "this")}} 值。</div>
+<div class="note">
+<p><strong>备注:</strong>如果使用<a href="/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions">箭头函数表达式</a>来传入函数参数, <code><var>thisArg</var></code> 参数会被忽略,因为箭头函数在词法上绑定了 {{jsxref("Operators/this", "this")}} 值。</p>
+</div>
</div>
<h3 id="对象复制器函数">对象复制器函数</h3>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html
index 5001b155be..3fdd124719 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html
@@ -28,8 +28,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/includes
<dd>
<p>需要查找的元素值。</p>
- <div class="blockIndicator note">
- <p><strong>Note: </strong>使用<strong> </strong><code>includes()</code>比较字符串和字符时是区分大小写的。</p>
+ <div class="note">
+ <p><strong>备注:</strong>使用<strong> </strong><code>includes()</code>比较字符串和字符时是区分大小写的。</p>
</div>
</dd>
<dt><code>fromIndex</code> {{optional_inline}}</dt>
@@ -43,7 +43,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/includes
<p>0 的值将全部视为相等,与符号无关(即 -0 与 0 和 +0 相等),但 <code>false</code> 不被认为与 0 相等。</p>
<div class="note">
-<p><strong>Note:</strong> 技术上来讲,<code>includes()</code> 使用 <code><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Equality_comparisons_and_sameness#%E9%9B%B6%E5%80%BC%E7%9B%B8%E7%AD%89">零值相等</a></code> 算法来确定是否找到给定的元素。</p>
+<p><strong>备注:</strong> 技术上来讲,<code>includes()</code> 使用 <code><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Equality_comparisons_and_sameness#%E9%9B%B6%E5%80%BC%E7%9B%B8%E7%AD%89">零值相等</a></code> 算法来确定是否找到给定的元素。</p>
</div>
<h2 id="示例">示例</h2>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/index.md b/files/zh-cn/web/javascript/reference/global_objects/array/index.md
index 70b70221e2..fa360b4d50 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/index.md
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/index.md
@@ -232,9 +232,9 @@ const myArray = myRe.exec('cdbBdbsbz')
<table class="fullwidth-table standard-table">
<thead>
<tr>
- <th class="header" scope="col">属性/元素</td>
- <th class="header" scope="col">说明</td>
- <th class="header" scope="col">示例</td>
+ <th scope="col">属性/元素</td>
+ <th scope="col">说明</td>
+ <th scope="col">示例</td>
</tr>
</thead>
<tbody>
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 a4ef7ead3b..3e24bae2c5 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
@@ -17,7 +17,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/indexOf
<div>{{EmbedInteractiveExample("pages/js/array-indexof.html")}}</div>
<div class="note">
-<p>注意:对于String方法,请参阅 {{jsxref("String.prototype.indexOf()")}}。</p>
+<p><strong>备注:</strong>对于String方法,请参阅 {{jsxref("String.prototype.indexOf()")}}。</p>
</div>
<h2 id="Syntax">语法</h2>
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 b4c06b6acb..defbf9c200 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
@@ -23,18 +23,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join
<dl>
<dt><code>separator</code> {{optional_inline}}</dt>
<dd>指定一个字符串来分隔数组的每个元素。如果需要,将分隔符转换为字符串。如果缺省该值,数组元素用逗号(<code>,</code>)分隔。如果<code>separator</code>是空字符串(<code>""</code>),则所有元素之间都没有任何字符。</dd>
- <dt>
- <h3 id="返回值">返回值</h3>
- </dt>
- <dd>一个所有数组元素连接的字符串。如果 <code>arr.length</code><strong> </strong>为0,则返回空字符串。</dd>
</dl>
+<h3 id="返回值">返回值</h3>
+
+<p>一个所有数组元素连接的字符串。如果 <code>arr.length</code><strong> </strong>为0,则返回空字符串。</p>
+
<h2 id="Description">描述</h2>
<p>所有的数组元素被转换成字符串,再用一个分隔符将这些字符串连接起来。</p>
-<div class="blockIndicator warning">
-<p>如果一个元素为 <code>undefined</code> 或 <code>null</code>,它会被转换为空字符串。</p>
+<div class="warning">
+<p><strong>警告:</strong>如果一个元素为 <code>undefined</code> 或 <code>null</code>,它会被转换为空字符串。</p>
</div>
<h2 id="Examples">示例</h2>
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 1ee4198226..6731fc1d14 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
@@ -82,7 +82,7 @@ function printEntries(arr) {
<p>下面的例子中,通过数组下标遍历数组元素,并把每个元素的值修改为原值的2倍。</p>
-<pre class="brush: js line-numbers language-js">var numbers = [1, 2, 3, 4, 5];
+<pre class="brush: js">var numbers = [1, 2, 3, 4, 5];
var length = numbers.length;
for (var i = 0; i &lt; length; i++) {
numbers[i] *= 2;
@@ -93,7 +93,7 @@ for (var i = 0; i &lt; length; i++) {
<p>下面的例子中,如果数组长度大于 3,则把该数组的长度截断为 3 。</p>
-<pre class="brush: js line-numbers language-js">var numbers = [1, 2, 3, 4, 5];
+<pre class="brush: js">var numbers = [1, 2, 3, 4, 5];
if (numbers.length &gt; 3) {
numbers.length = 3;
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
index d52d65e268..348d717a0f 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
@@ -74,7 +74,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/Reduce
<p>回调函数第一次执行时,<code>accumulator</code> 和<code>currentValue</code>的取值有两种情况:如果调用<code>reduce()</code>时提供了<code>initialValue</code>,<code>accumulator</code>取值为<code>initialValue</code>,<code>currentValue</code>取数组中的第一个值;如果没有提供 <code>initialValue</code>,那么<code>accumulator</code>取数组中的第一个值,<code>currentValue</code>取数组中的第二个值。</p>
<div class="note">
-<p><strong>注意:</strong>如果没有提供<code>initialValue</code>,reduce 会从索引1的地方开始执行 callback 方法,跳过第一个索引。如果提供<code>initialValue</code>,从索引0开始。</p>
+<p><strong>备注:</strong>如果没有提供<code>initialValue</code>,reduce 会从索引1的地方开始执行 callback 方法,跳过第一个索引。如果提供<code>initialValue</code>,从索引0开始。</p>
</div>
<p>如果数组为空且没有提供<code>initialValue</code>,会抛出{{jsxref("TypeError")}} 。如果数组仅有一个元素(无论位置如何)并且没有提供<code>initialValue</code>, 或者有提供<code>initialValue</code>但是数组为空,那么此唯一值将被返回并且<code>callback</code>不会被执行。</p>
@@ -450,8 +450,8 @@ var allbooks = friends.reduce(function(prev, curr) {
<h3 id="数组去重">数组去重</h3>
-<div class="blockIndicator note">
-<p>注意: 如果你正在使用一个可以兼容{{jsxref("Set")}} 和 {{jsxref("Array.from()")}} 的环境, 你可以使用<code>let orderedArray = Array.from(new Set(myArray));</code> 来获得一个相同元素被移除的数组。</p>
+<div class="note">
+<p><strong>备注:</strong> 如果你正在使用一个可以兼容{{jsxref("Set")}} 和 {{jsxref("Array.from()")}} 的环境, 你可以使用<code>let orderedArray = Array.from(new Set(myArray));</code> 来获得一个相同元素被移除的数组。</p>
</div>
<pre class="brush: js">let myArray = ['a', 'b', 'a', 'b', 'c', 'e', 'e', 'c', 'd', 'd', 'd', 'd']
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
index 793a4fd3a3..8517f6e749 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
@@ -27,28 +27,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
<dl>
<dt><code>callback</code></dt>
<dd>一个回调函数,用于操作数组中的每个元素,它可接受四个参数:
- <dl>
- <dt><code>accumulator</code></dt>
- <dd>累加器:上一次调用回调函数时,回调函数返回的值。首次调用回调函数时,如果 <code>initialValue</code> 存在,累加器即为 <code>initialValue</code>,否则须为数组中的最后一个元素(详见下方 <code>initialValue</code> 处相关说明)。</dd>
- <dt><code>currentValue</code></dt>
- <dd>当前元素:当前被处理的元素。</dd>
- <dt><code>index</code>{{optional_inline}}</dt>
- <dd>数组中当前被处理的元素的索引。</dd>
- <dt><code>array</code>{{optional_inline}}</dt>
- <dd>调用 <code>reduceRight()</code> 的数组。</dd>
- </dl>
+ <dl>
+ <dt><code>accumulator</code></dt>
+ <dd>累加器:上一次调用回调函数时,回调函数返回的值。首次调用回调函数时,如果 <code>initialValue</code> 存在,累加器即为 <code>initialValue</code>,否则须为数组中的最后一个元素(详见下方 <code>initialValue</code> 处相关说明)。</dd>
+ <dt><code>currentValue</code></dt>
+ <dd>当前元素:当前被处理的元素。</dd>
+ <dt><code>index</code>{{optional_inline}}</dt>
+ <dd>数组中当前被处理的元素的索引。</dd>
+ <dt><code>array</code>{{optional_inline}}</dt>
+ <dd>调用 <code>reduceRight()</code> 的数组。</dd>
+ </dl>
</dd>
<dt><code>initialValue</code>{{optional_inline}} </dt>
<dd>首次调用 <code>callback</code> 函数时,累加器 <code>accumulator</code> 的值。如果未提供该初始值,则将使用数组中的最后一个元素,并跳过该元素。如果不给出初始值,则需保证数组不为空。<br>
否则,在空数组上调用 <code>reduce</code> 或 <code>reduceRight</code> 且未提供初始值(例如 <code>[].reduce( (acc, cur, idx, arr) =&gt; {} )</code> )的话,会导致类型错误 <code><a href="/zh-CN/docs/Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value">TypeError: reduce of empty array with no initial value</a></code>。</dd>
- <dt>
- <h3 id="返回值">返回值</h3>
- </dt>
- <dd>
- <p>执行之后的返回值。</p>
- </dd>
</dl>
+<h3 id="返回值">返回值</h3>
+
+<p>执行之后的返回值。</p>
+
<h2 id="描述">描述</h2>
<p><code>reduceRight</code> 为数组中每个元素调用一次 <code>callback</code> 回调函数,但是数组中被删除的索引或从未被赋值的索引会跳过。回调函数接受四个参数:初始值(或上次调用回调的返回值)、当前元素值、当前索引,以及调用迭代的当前数组。</p>
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 b20d27f664..2d44c8dc8d 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
@@ -58,8 +58,8 @@ var citrus = fruits.slice(1, 3);
// citrus contains ['Orange','Lemon']
</pre>
-<div class="standardNoteBlock">
-<p class="syntaxbox"><strong>译者注:citrus</strong> <em>[n.]</em> 柑橘类果实</p>
+<div class="callout">
+<p><strong>标注:</strong> citrus <em>[n.]</em> 柑橘类果实——译注</p>
</div>
<h3 id="使用_slice">使用 <code>slice</code></h3>
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 a0f5695dfb..7d5102b182 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
@@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some
<p><code><strong>some()</strong></code> 方法测试数组中是不是至少有1个元素通过了被提供的函数测试。它返回的是一个Boolean类型的值。</p>
<div class="note">
-<p><strong>注意:</strong>如果用一个空数组进行测试,在任何情况下它返回的都是<code>false</code>。</p>
+<p><strong>备注:</strong>如果用一个空数组进行测试,在任何情况下它返回的都是<code>false</code>。</p>
</div>
<div>{{EmbedInteractiveExample("pages/js/array-some.html")}}</div>
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 49a4339d87..51bb55254e 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
@@ -100,7 +100,7 @@ console.log(numbers);
<p>对象可以按照某个属性排序:</p>
-<pre class="brush: js line-numbers language-js">var items = [
+<pre class="brush: js">var items = [
{ name: 'Edward', value: 21 },
{ name: 'Sharpe', value: 37 },
{ name: 'And', value: 45 },
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
index 92e3920d88..cbfc745614 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
@@ -53,8 +53,8 @@ iterator.next(); // Object { value: "e", done: false }
iterator.next(); // Object { value: undefined, done: true }
iterator.next().value; // undefined</pre>
-<div class="blockIndicator warning">
-<p>一次性:数组迭代器是一次性的,或者说临时对象</p>
+<div class="warning">
+<p><strong>警告:</strong>一次性:数组迭代器是一次性的,或者说临时对象</p>
</div>
<p>例子:</p>
@@ -80,8 +80,8 @@ arr[1] = 'n';
iterator.next().value; // "n"
</pre>
-<div class="blockIndicator note">
-<p>如果数组中元素改变,那么迭代器的值也会改变</p>
+<div class="note">
+<p><strong>备注:</strong>如果数组中元素改变,那么迭代器的值也会改变</p>
</div>
<h2 id="规范">规范</h2>