DEV Community

Discussion on: 5 JavaScript "tips" that might bite you back.

Collapse
 
paulsmithkc profile image
Paul Smith

This instantiates n+1 new arrays (where n is the number of arrays), when you could have just used a for loop to instantiate 1 new array.

Thread Thread
 
eecolor profile image
EECOLOR

Did you read the comment of @josh to which I replied?

Granted, the spread operator being used in the returned array like this means you'll be generating copies upon copies upon copies, but you asked for an arity-agnostic refactor, not a performant one 😜