loading...

re: 2 Ways to Merge Arrays in JavaScript VIEW POST

FULL DISCUSSION
 

Maybe it's a little bit longer, but you don't have to create an array just to use the prototypes concat method.

Instead of

[].concat([1,2],[3,4])

you could also write that one:

Array.prototype.concat([1,2],[3,4])
 

nice, thanks for sharing that 👍

 

Just for fun I tried it on jsperf and the first one is way faster. Never thought that. But it's probably just a micro optimization.

jsperf.com/empty-array-conact-vs-p...

code of conduct - report abuse