Skip to content

indexOf

Subhajit Sahu edited this page Feb 3, 2021 · 14 revisions

Finds first index of a value. 🏃 📼 📦 🌔 📒

Alternatives: indexOf, lastIndexOf.
Similar: search, indexOf, hasValue, includes.

iterable.indexOf(x, v, [i]);
// x: an iterable
// v: search value
// i: start index (0)
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