-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[zh-TW]: update Array.prototype.find()
#26882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
Preview URLs External URLs (2)URL:
(comment last updated: 2025-04-23 05:19:35) |
--- | ||
|
||
{{JSRef}} | ||
|
||
**`find()`** 方法會回傳第一個滿足所提供之測試函式的元素**值**。否則回傳 {{jsxref("undefined")}}。 | ||
{{jsxref("Array")}} 實例的 **`find()`** 方法會回傳在提供的陣列中,第一個通過所提供測試函式的元素。如果沒有任何值通過測試函式,則回傳 {{jsxref("undefined")}}。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得 {{jsxref("Array")}} 實例的 **
find()** 方法會回傳在提供的陣列中,第一個通過所提供測試函式的元素
中间的逗号有点割裂语义
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
`callback` 函式被呼叫時會傳入三個參數:元素的值、元素索引,以及正被迭代的陣列物件。 | ||
|
||
如果提供 `thisArg` 參數予 `find`,其將會被當作 `callback` 每次被呼叫的 `this`。若是沒提供,則會使用 {{jsxref("undefined")}}。 | ||
`find()` 方法是一個[迭代方法](/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array#迭代方法)。它會以索引遞增順序對陣列中的每個元素執行一次所提供的 `callbackFn` 函式,直到 `callbackFn` 回傳一個 [truthy](/zh-TW/docs/Glossary/Truthy) 值。此時,`find()` 會回傳該元素並停止迭代陣列。若 `callbackFn` 未曾回傳 truthy 值,則 `find()` 會回傳 {{jsxref("undefined")}}。請參閱[迭代方法](/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Array#迭代方法)部分以深入了解這些方法的運作方式。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一样的
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
- {{jsxref("Array.prototype.every()")}} – test all elements together | ||
- [在 `core-js` 中 `Array.prototype.find` 的 Polyfill](https://github.com/zloirock/core-js#ecmascript-array) | ||
- [`Array.prototype.find` 的 es-shims polyfill](https://www.npmjs.com/package/array.prototype.find) | ||
- [索引集合](/zh-TW/docs/Web/JavaScript/Guide/Indexed_collections)教學 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guide是翻译为教学还是指引还是指南
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
files/zh-tw/web/javascript/reference/global_objects/array/find/index.md
Outdated
Show resolved
Hide resolved
Co-authored-by: A1lo <yin199909@aliyun.com>
Description
Motivation
Additional details
Related issues and pull requests