find - nodef/extra-lists GitHub Wiki

Find first value passing a test (default order).

Alternatives: find, findAll. Similar: find, search, searchValue.

function find(x, ft)
// x:  lists
// ft: test function (v, k, x)
const xlists = require('extra-lists');

var x = ['a', 'b', 'c', 'd'], [1, 2, 3, 4](/nodef/extra-lists/wiki/'a',-'b',-'c',-'d'],-[1,-2,-3,-4);
xlists.find(x, v => v % 2 === 0);
// → 2                             ^

xlists.find(x, v => v % 8 === 0);
// → undefined

References