JSPM

  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q41408F
  • License MIT

Finds last index of a value.

Package Exports

  • @extra-array/search-value-right.min

Readme

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

Alternatives: searchValue, searchValueRight, searchValueAll.
Similar: search, scan, find.
This is part of package extra-array.

This is browserified, minified version of @extra-array/search-value-right.
It is exported as global variable array_searchValueRight.
CDN: unpkg, jsDelivr.

array.searchValueRight(x, v, [fc], [fm]);
// x:  an array
// v:  search value
// fc: compare function (a, b)
// fm: map function (v, i, x)
// --> index of value, -1 if not found
const array = require('extra-array');

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

var x = [1, 2, 3, -2, 5];
array.searchValueRight(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
// 3               ^

array.searchValueRight(x, 2, null, v => Math.abs(v));
// 3               ^

references