Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Maximum number of items that can be safely passed into .apply(...) invocation
// Description: The code below fails in two major browsers due to exceeding number
// of argumnets that can be safely passed into `.apply(...)`
// invocation of the `test(...)` function.
(function(){
console.clear();
upperBound = {};
// Substruct 1 to let the magic happen
upperBound.Chrome = Math.pow(2, 16) + 55155;
upperBound.Firefx = Math.pow(2, 18) + 237857;
let size = navigator.product === "Gecko"
? upperBound.Firefx
: upperBound.Chrome;
let args = new Array(size).fill(null);
let test = function(){};
test(...args); // fail
test.apply(null, args); // same, but for ...apply(...)
console.log(`Call is over!`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment