Skip to content
Subhajit Sahu edited this page Feb 3, 2021 · 25 revisions

Find largest value.

Similar: min, minEntry, max, maxEntry, range, rangeEntries.


function max(x, fc, fm)
// x:  an iterable
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xiterable = require('extra-iterable');

var x = [1, 2, -3, -4];
xiterable.max(x);
// → 2

xiterable.max(x, (a, b) => Math.abs(a) - Math.abs(b));
// → -4

xiterable.max(x, null, v => Math.abs(v));
// → -4


References

Clone this wiki locally