3 ms·
Why is atoa() being used on arguments? You can pass an arguments object to apply(). It even avoids deoptimization (at least on V8), IIRC. (No explanation at htt
by minitech 10y ago
Why is atoa() being used on arguments? You can pass an arguments object to apply(). It even avoids deoptimization (at least on V8), IIRC. (No explanation at https://github.com/bevacqua/react-dragula/commit/916c5fe4900eca47c07e139d1e0783ca7c6ba814 https://github.com/bevacqua/react-dragula/commit/916c5fe4900...)
- wanda 10y agoThis 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...
- rhinoceraptor 10y agoIf you're using ES2015, you can do let argArray = (...args) => doStuffWithArgArray(...args)