Math.max(...list) Math.max(...list)e.g.,
Math.max(...Array(100_0000).fill(0))
results in: Uncaught RangeError: Maximum call stack size exceededIt's not at all clear to me why this would be a necessary limit to exist, as functions can't reasonably have more than a few hundred formal parameters so passing 100,000 would always imply using unspread or arguments on the receiver, which could surely trivially handle arbitrarily sized arrays.
OTOH, Webkit and Firefox have arbitrary limits 65537, and 500k args.
https://bugs.webkit.org/show_bug.cgi?id=80797 https://github.com/mozilla/gecko-dev/blob/1475b3b0cb274b2a71...
> ... wincing slightly at the lambda notation you need to avoid running afoul of JavaScript’s variadic Math.max()...
list.reduce((x,y)=>Math.max(x,y))
To get the max number in a list. And he is "winching" because he can't write: list.reduce(Math.max)
Because the variable arity of max does not play well with reduce. But because of the variable arity he can write: Math.max(...list)
Which is even simpler.So he deliberately writes overly complex JavaScript code to show how the other language is more concise.
So worthwhile keeping in mind that the nice JS code falls apart.
And if you think lodash is still to verbose, you can define your own:
const å = list => list.reduce((x,y) => Math.max(x, y));
Now you can write å(list) to get the max value of an array!