3 ms·
I'd go with `Math.max(...arr)` personally. Math.max is a variadic function, no need to add a reduce into the mix.
by hmsimha 5y ago
I'd go with `Math.max(...arr)` personally. Math.max is a variadic function, no need to add a reduce into the mix.
- roryokane 5y agoThat implicitly calls Function.prototype.apply(), which will fail if given more arguments than an implementation-specific limit (https://stackoverflow.com/questions/22747068/is-there-a-max-number-of-arguments-javascript-functions-can-accept https://stackoverflow.com/questions/22747068/is-there-a-max-...). Looping with reduce() avoids that restriction.