Created
July 20, 2020 20:56
-
-
Save hinell/3148837767e41d2181718ebbfca1990f to your computer and use it in GitHub Desktop.
Maximum number of items that can be safely passed into .apply(...) invocation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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