Skip to content
Subhajit Sahu edited this page Feb 4, 2021 · 14 revisions

Finds key of an entry passing a test. 📦 😺 🏃 📼 🌔 📜 📰 📘

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