> For the complete documentation index, see [llms.txt](https://jscula.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jscula.gitbook.io/docs/array/rotate.md).

# rotate()

Moves the first item in an array to the end.

```javascript
const queue = ['first', 'second', 'third'];

queue.rotate(); // ['second', 'third', 'first']
```

### Use cases

Use `rotate()` to cycle through ordered items:

* Advance a slideshow to its next item.
* Move the next support ticket to the end of a queue.
* Rotate a round-robin assignment list.

### More examples

Advance a slideshow queue:

```javascript
const slides = ['intro', 'features', 'pricing'];

slides.rotate(); // ['features', 'pricing', 'intro']
```

Rotate team assignments after each task:

```javascript
const assignees = ['Ada', 'Lin', 'Sam'];
const nextAssignee = assignees[0];

assignees.rotate();
```
