13 lines
424 B
Markdown
13 lines
424 B
Markdown
|
---
|
||
|
title: Manipulate Arrays With unshift()
|
||
|
---
|
||
|
## Manipulate Arrays With unshift()
|
||
|
|
||
|
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
||
|
While `push()` added elements to the back of the array, `unshift()` adds them to the front. All you have to do is:
|
||
|
|
||
|
```javascript
|
||
|
var arr = [2, 3, 4, 5];
|
||
|
arr.unshift(1); // Now, the array has 1 in the front
|
||
|
```
|