diff options
author | Irvin <irvinfly@gmail.com> | 2022-02-16 02:14:18 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | d44f5032d0f53256b2d5aef505d6b593fd3cd158 (patch) | |
tree | 4b585f4be9c9a2712664ad10e7acf62c83fff51f /files/zh-cn/web/javascript/reference/global_objects/array/reduceright | |
parent | f45e9e070c93ebbd83d488bdd775987a4d75c201 (diff) | |
download | translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.gz translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.bz2 translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.zip |
fix yari h2m dry run errors (zh-CN)
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/array/reduceright')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html | 30 |
1 files changed, 14 insertions, 16 deletions
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) => {} )</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> |