If it was an array, it's trivial with Array.splice:
> x = ['image0', 'image1', 'image2', 'image3'];
[ 'image0',
'image1',
'image2',
'image3' ]
> x = x.splice(2).concat(x)
[ 'image2',
'image3',
'image0',
'image1' ]
> x = ['image0', 'image1', 'image2', 'image3'];
[ 'image0',
'image1',
'image2',
'image3' ]
> x = x.splice(3).concat(x)
[ 'image3',
'image0',
'image1',
'image2' ]
>
Splice does in-place chopping out of stuff, what you're left with is the spliced first two elements. We put that into X. The original array is modified in place, so it points to what it was at the original referencing time, so, the remaining n elements. So you concat to those remaining elements the spliced first two.
You can even use negative values and play with it, move forward and backward:
> x = ['image0', 'image1', 'image2', 'image3'];
[ 'image0',
'image1',
'image2',
'image3' ]
> x = x.splice(-1).concat(x)
[ 'image3',
'image0',
'image1',
'image2' ]
> x = x.splice(1).concat(x)
[ 'image0',
'image1',
'image2',
'image3' ]
> x = x.splice(-3).concat(x)
[ 'image1',
'image2',
'image3',