-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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 Chrome 72 for Windows.
JQuery version: 3.3.1
Sample code:
$.map(new Array(300000), i => 1)Internally it calls to concat.apply and crashes there.
As long as I understand, apply tries to push all elements of the array into the stack before invoking the function concat and fails on stack shortage.
I believe that any function being invoked thru apply with a large array as an argument will fail.
I've found about 14 usages of apply in the code of jQuery. I would suggest you to check out all of these cases.
OlehDutchenko and liujinlll