I was wondering what was the most efficient way to rotate a JavaScript array.
I came up with this solution, where a positive n rotates the array to the
n
Not sure about the efficiency but I would do it in this non mutating way :
Array.prototype.rotate = function( n ) { return this.map( (item, index)=> this[ (this.length + index + n)%this.length ] ) }