Skip to content
Subhajit Sahu edited this page Dec 22, 2022 · 13 revisions

Finds key of an entry passing a test.

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


function search(x, ft)
// x:  entries
// ft: test function (v, k, x)
const entries = require('extra-entries');

var x = [["a", 1], ["b", 2], ["c", 3], ["d", 2]];
entries.search(x, v => v === 2);
// → "b"                       ^

entries.search(x, v => v === 4);
// → undefined


References

Clone this wiki locally