Skip to content
Subhajit Sahu edited this page Jun 11, 2020 · 14 revisions

Finds key of an entry passing a test. 🏃 📼 📦 🌔 📒

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

object.search(x, fn, [ths]);
// x:   an object
// fn:  test function (v, k, x)
// ths: this argument
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