Skip to content
Subhajit Sahu edited this page Dec 2, 2022 · 17 revisions

Find first value passing a test (default order).

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


function find(x, ft)
// x:  a set
// ft: test function (v, v, x)
const set = require('extra-set');

var x = new Set([1, 2, 3, 4]);
set.find(x, v => v % 2 === 0);
// → 2                             ^

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


References

Clone this wiki locally