Skip to content
Subhajit Sahu edited this page Dec 8, 2022 · 14 revisions

Find key of an entry passing a test.

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


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

var x = {a: 1, b: 2, c: 3, d: 2};
object.search(x, v => v === 2);
// → 'b'         ^

object.search(x, v => v === 4);
// → null


References

Clone this wiki locally