Skip to content

find() function

Iterable/AsyncIterable의 각 값을 살펴보고, 진리 테스트 f를 통과하는 첫 번째 값을 반환하거나, 통과하는 값이 없으면 undefined를 반환합니다.

Signature:

typescript
declare function find<T>(
  f: (a: T) => unknown,
  iterable: Iterable<T>,
): T | undefined;

Example

ts
find((a) => a === 2, [1, 2, 3, 4]); // 2

find((a) => a === "r", "marpple"); // 'r'

Try It

Open Source Code

Released under the Apache-2.0 License.