-
Notifications
You must be signed in to change notification settings - Fork 5
indexOf
Subhajit Sahu edited this page Nov 20, 2022
·
15 revisions
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: start index [0]
const array = require('extra-array');
var x = [1, 2, 3, 2, 5];
array.indexOf(x, 2);
// → 1 ^
var x = [1, 2, 3, 2, 5];
array.indexOf(x, 2, 2);
// → 3 ^