-
Notifications
You must be signed in to change notification settings - Fork 5
maximum
Subhajit Sahu edited this page May 3, 2023
·
1 revision
Find first largest value.
Alternatives: maximum, maximumEntry.
Similar: minimum, maximum, range.
function maximum(x, fc, fm)
// x: an array
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xarray = require('extra-array');
var x = [1, 2, -3, -4];
xarray.max(x);
// → 2
xarray.max(x, (a, b) => Math.abs(a) - Math.abs(b));
// → -4
xarray.max(x, null, v => Math.abs(v));
// → -4