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

Finds key of an entry passing a test. 🏃 [:vhs:] 📦 🌔 📒

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

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

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

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

references

Clone this wiki locally