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 --- .../javascript/reference/global_objects/array/find/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/array/find') 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")}}

-

相关链接

+

相关链接