4 ms·
This is indeed true for V8 IIRC, but even if it weren't, both arguments.length and arguments[x] are safe to use without stopping optimisation, so even a very ca
by wanda 10y ago
This is indeed true for V8 IIRC, but even if it weren't, both arguments.length and arguments[x] are safe to use without stopping optimisation, so even a very cautious JavaScript dev can effectively clone the arguments object in a roundabout sort of way and pass it to apply, like so:
// given a context and function 'func'
var args = [];
for(var i = 0; i < arguments.length; i++){
args[i] = arguments[i];
}
func.apply(context, args);
Source: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers https://github.com/petkaantonov/bluebird/wiki/Optimization-k...