Skip to main content

findIndex()

findIndex<T>(predicate): (arr) => number

Returns the first index of the given array that satisfies the predicate. Returns -1 otherwise.

Type Parameters

T

T

The type of array elements.

Parameters

predicate

Predicate<T>

A predicate function to apply to each element of the array.

Returns

(arr): number

Parameters

arr

T[]

Returns

number

Remarks

pure function

Example

import { findIndex } from '@accelint/core';

findIndex(x => !(x & 1))([1, 2, 3, 4, 5]);
// 1