loading...

re: Is JavaScript's .shift() Method a Performance Boost? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Thanks Mike for pointing out the potential costly operation of shift -- I read somewhere that also compared shift with push and pop, but your expla...
 

Yeah we can do it without spread - but now it looks nicer in ES6 :)

    function rotateLeft(array, n) {
      n = n % array.length
      return array.push.apply(array, array.splice(0, n))
    }
code of conduct - report abuse