On Wed, Nov 21, 2018 at 7:23 AM Isiah Meadows <[email protected]> wrote: > > It doesn't work as well with larger collections.
For example, fails at somewhere between an array of length 125,000 and 126,000 on V8 in Chrome v70 (as does the `apply` trick, so the proposed polyfill would have the same problem): http://jsfiddle.net/xoLe5mg7/ Using spread (it's not rest) also means that it would have to go through an iterator, which if the iterable is known to be an array is a lot of extra overhead (but also makes it more generally useful, so, swings and roundabouts). @Gbadebo Bello - What makes `reduce` not suitable to your use cases? Example: ```js function findMin(array) { return array.reduce((a, b) => a < b ? a : b); } ``` or if you want the type check: ```js function findMin(array) { return array.reduce((a, b) => { if (typeof a !== "number" || typeof b !== "number") { throw new Error("The array must contain only numbers"); } return a < b ? a : b; }); } ``` (both off-the-cuff, apologies if there are any minor errors; the overall point should be clear regardless.) If the callback becomes important from a performance perspective, I'd expect it to get aggressively optimized. -- T.J. Crowder
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

