-
Notifications
You must be signed in to change notification settings - Fork 5
find
Subhajit Sahu edited this page May 11, 2020
·
23 revisions
Finds first value passing a test. 🏃 📼 📦 🌔
array.find(x, fn, [ths]);
// x: an array
// fn: test function (v, i, x)
// ths: this argument
const array = require('extra-array');
var x = [1, 2, 3, 4, 5];
array.find(x, v => v % 2 == 0);
// 2 ^
var x = [1, 2, 3, 4, 5];
array.find(x, v => v % 2 == 1);
// 1 ^