@extra-array/max-index
v2.9.2
Published
Finds index of largest value.
Maintainers
Readme
Finds index of largest value. :running: :vhs: :package: :moon: :ledger:
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 ^