Creates a function that accepts up to n arguments, ignoring any additional arguments.
Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).
constary = (fn, n) => (...args) => fn(...args.slice(0, n));
Usage:
constfirstTwoMax = ary(Math.max,2);
[[2,6,'a'], [8,4,6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
From:
https://github.com/Chalarangelo/30-seconds-of-code
https://30secondsofcode.org/