indexOf - nodef/extra-array GitHub Wiki

Find first index of a value.

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

function indexOf(x, v, i)
// x: an array
// v: search value
// i: begin index [0]
const xarray = require('extra-array');

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

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

References