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
How about incrementing a counter and then getting the remainder of a division by the array length to get where you are supposed to be.
var i = 0; while (true); { var position = i % months.length; alert(months[position]); ++i; }
Language syntax aside this should work fine.