That requires making a copy of the array to iterate over it. I was about to say that iteration with an index is probably way faster than shift, but check this out: http://jsperf.com/loop-iteration-length-comparison-variations/7

Apparently, reversing, and then iterating with pop is the fastest. Even with making an array copy!