-
Notifications
You must be signed in to change notification settings - Fork 5
searchAll
Subhajit Sahu edited this page May 19, 2020
·
23 revisions
Searches a value throughout. 🏃 📼 📦 🌔
array.searchAll(x, v, [fn]);
// x: an array
// v: search value
// fn: compare function (a, b)
// --> indices of value
const array = require('extra-array');
var x = [1, 2, 3, 2, 5];
array.searchAll(x, 2);
// [ 1, 3 ] ^ ^
var x = [1, 2, 3, -2, 5];
array.searchAll(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
// [ 1, 3 ] ^ ^
array.searchAll(x, 2, null, v => Math.abs(v));
// [ 1, 3 ] ^ ^