- Notifications
You must be signed in to change notification settings - Fork20.6k
Closed
Labels
Milestone
Description
When a large array is passed as an argument to$.map()
we get an error:
RangeError: Maximum call stack size exceeded
Tested on Chrome72 for Windows.
JQuery version:3.3.1
Sample code:
$.map(newArray(300000),i=>1)
Internally it calls toconcat.apply
and crashes there.
As long as I understand,apply
tries to push all elements of the array into the stack before invoking the functionconcat
and fails on stack shortage.
I believe that any function being invoked thruapply
with a large array as an argument will fail.
I've found about 14 usages ofapply
in the code of jQuery. I would suggest you to check out all of these cases.