@extra-array/find-index
v2.9.12
Published
Finds index of leftmost value passing a test.
Downloads
275
Maintainers
Readme
Finds index of leftmost value passing a test. :running: :vhs: :package: :moon: :ledger:
Alternatives: findIndex, findIndices. Similar: find, findIndex. This is part of package extra-array.
array.findIndex(x, fn);
// x: an array
// fn: test function (v, i, x)
// --> index of value, -1 if not found
const array = require('extra-array');
var x = [1, 2, 3, 4, 5];
array.findIndex(x, v => v % 2 == 0);
// 1 ^
array.findIndex(x, v => v % 2 == 1);
// 0 ^