2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Manipulate Arrays With unshift()
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Manipulate Arrays With unshift()
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
|
|
|
|
|
|
|
### Hint 1
|
2018-10-12 15:37:13 -04:00
|
|
|
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
|
|
|
|
```
|