Files

13 lines
342 B
Markdown
Raw Normal View History

---
title: Manipulate Arrays With unshift()
localeTitle: 使用unshift操作数组
---
## 使用unshift操作数组
`push()`向元素的后面添加元素时, `unshift()`会将它们添加到前面。你所要做的就是:
```javascript
var arr = [2, 3, 4, 5];
arr.unshift(1); // Now, the array has 1 in the front
```