JSPM

  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q58616F
  • License MIT

Finds index of largest value.

Package Exports

  • @extra-array/max-index

Readme

Finds index of largest value. 🏃 📼 📦 🌔 📒

Alternatives: max, maxIndex.
Similar: min, max, range.
This is part of package extra-array.

array.maxIndex(x, [fc], [fm]);
// x:  an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
const array = require('extra-array');

var x = [1, 2, -3, -4];
array.maxIndex(x);
// 1        ^

array.maxIndex(x, (a, b) => Math.abs(a) - Math.abs(b));
// 3                ^

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

references