Skip to content
Subhajit Sahu edited this page May 9, 2020 · 25 revisions

Finds largest value. 🏃 📼 📦 🌔

Alternatives: compare, map.

iterable.max(x, [fn]);
// x:  an iterable
// fn: compare function (a, b)
const iterable = require('extra-iterable');

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

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

references

Clone this wiki locally