-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Using the spread op in an ES6 function:
function foo(...args){
compiles to something like:
function foo(args){
args = [].slice.call(arguments, 0);
}
This leaks and prevents compiler optimization (There's about a 20x slowdown here). As much as I dislike code bloating, I believe it should compile to:
function foo(args){
args=[];
for(var i=0, l=arguments.length; i<l; i++){ args.push(arguments[i])); }
}
or similiar (obviously slightly different if the spread isn't the first argument).