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.
When a large array is passed as an argument to
$.map()we get an error:Tested on Chrome 72 for Windows.
JQuery version: 3.3.1
Sample code:
Internally it calls to
concat.applyand crashes there.As long as I understand,
applytries to push all elements of the array into the stack before invoking the functionconcatand fails on stack shortage.I believe that any function being invoked thru
applywith a large array as an argument will fail.I've found about 14 usages of
applyin the code of jQuery. I would suggest you to check out all of these cases.