-
Notifications
You must be signed in to change notification settings - Fork 5
find
Subhajit Sahu edited this page Feb 2, 2021
·
23 revisions
Finds first value passing a test. 📦 😺 🏃 📼 🌔 📜 📰 📘
Alternatives: find, findRight, findAll.
Similar: search, scan, find.
array.find(x, ft);
// x: an array
// ft: test function (v, i, x)
const array = require("extra-array");
var x = [1, 2, 3, 4, 5];
array.find(x, v => v % 2 == 0);
// 2 ^
array.find(x, v => v % 2 == 1);
// 1 ^