Skip to content

lastIndexOf

Subhajit Sahu edited this page May 19, 2020 · 15 revisions

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

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

array.lastIndexOf(x, v, [i]);
// x: an array
// v: search value
// i: start index
const array = require('extra-array');

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

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

references

Clone this wiki locally