DEV Community

Discussion on: Is JavaScript's .shift() Method a Performance Boost?

Collapse
 
lionelrowe profile image
lionel-rowe • Edited

It looks like you could get better perf (at least for long arrays) using Array#concat without the spread operator:

jsperf.com/concat-vs-spreader

Also remember that Array#push returns the pushed item new length of the array, not the array 😉

Collapse
 
miketalbot profile image
Mike Talbot ⭐

You're right, should have a , array at the end I guess or a separate line