From d44f5032d0f53256b2d5aef505d6b593fd3cd158 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:14:18 +0800 Subject: fix yari h2m dry run errors (zh-CN) --- .../global_objects/array/reduceright/index.html | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/array/reduceright') 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
callback
一个回调函数,用于操作数组中的每个元素,它可接受四个参数: -
-
accumulator
-
累加器:上一次调用回调函数时,回调函数返回的值。首次调用回调函数时,如果 initialValue 存在,累加器即为 initialValue,否则须为数组中的最后一个元素(详见下方 initialValue 处相关说明)。
-
currentValue
-
当前元素:当前被处理的元素。
-
index{{optional_inline}}
-
数组中当前被处理的元素的索引。
-
array{{optional_inline}}
-
调用 reduceRight() 的数组。
-
+
+
accumulator
+
累加器:上一次调用回调函数时,回调函数返回的值。首次调用回调函数时,如果 initialValue 存在,累加器即为 initialValue,否则须为数组中的最后一个元素(详见下方 initialValue 处相关说明)。
+
currentValue
+
当前元素:当前被处理的元素。
+
index{{optional_inline}}
+
数组中当前被处理的元素的索引。
+
array{{optional_inline}}
+
调用 reduceRight() 的数组。
+
initialValue{{optional_inline}} 
首次调用 callback 函数时,累加器 accumulator 的值。如果未提供该初始值,则将使用数组中的最后一个元素,并跳过该元素。如果不给出初始值,则需保证数组不为空。
否则,在空数组上调用 reducereduceRight 且未提供初始值(例如 [].reduce( (acc, cur, idx, arr) => {} ) )的话,会导致类型错误 TypeError: reduce of empty array with no initial value
-
-

返回值

-
-
-

执行之后的返回值。

-
+

返回值

+ +

执行之后的返回值。

+

描述

reduceRight 为数组中每个元素调用一次 callback 回调函数,但是数组中被删除的索引或从未被赋值的索引会跳过。回调函数接受四个参数:初始值(或上次调用回调的返回值)、当前元素值、当前索引,以及调用迭代的当前数组。

-- cgit v1.2.3-54-g00ecf