Skip to content

lastIndexOf

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

Find last index of a value.

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


function lastIndexOf(x, v, i)
// x: an iterable
// v: search value
// i: start index [END-1]
const xiterable = require('extra-iterable');

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

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


References

Clone this wiki locally