I have attempted to add min() and max() functions to arrays, implemented using the ... operator:
Array.prototype.min = Array.prototype.min || function () {
return Math.min(...this);
};
However, when calling these functions on large arrays, I get an exception: "RangeError: Maximum call stack size exceeded". What is going on?
console.log(new Array(100000).min()); /* works */
console.log(new Array(1000000).min()); /* error */