Skip to content

indexOf

Subhajit Sahu edited this page May 13, 2020 · 14 revisions

Searches a value from left. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:]

Alternatives: [indexOf], [lastIndexOf].

iterable.search(x, v, [fn]);
// x:  an iterable
// v:  search value
// fn: compare function (a, b)
// --> index of value, -1 if not found
const iterable = require('extra-iterable');

var x = [1, 2, 3, 2, 5];
iterable.indexOf(x, 2);
// 1        ^

var x = [1, 2, 3, 2, 5];
iterable.indexOf(x, 2, 2);
// 3              ^

references

Clone this wiki locally