DEV Community

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

Collapse
 
miketalbot profile image
Mike Talbot ⭐

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))
    }