Why are too many arguments used to exceed the "Maximum Call Stack Size"?

In Chrome and Node, the following code causes an error:

function noop() {}
var a = new Array(1e6)
// Array[1000000]
noop.apply(null, a)
// Uncaught RangeError: Maximum call stack size exceeded

I understand why Bad Idea can pass 1 million arguments to a function, but can anyone explain why the error is Maximum call stack size exceededinstead of something more relevant?

(In case this seems frivolous, the original case was Math.max.apply(Math, lotsOfNumbers), which is an unreasonable way to get the maximum number from an array.)

+6
source share
1 answer

. , , . .

+8

Source: https://habr.com/ru/post/1015014/


All Articles