freeCodeCamp/guide/chinese/certifications/javascript-algorithms-and-d.../basic-javascript/manipulate-arrays-with-pop/index.md

25 lines
576 B
Markdown
Raw Normal View History

---
title: Manipulate Arrays With pop()
localeTitle: 使用pop操作数组
---
## 使用pop操作数组
## 问题解释
摆脱数组中的最后一个元素。然后,将该骑行元素分配给`removedFromMyArray` 。
## 提示1
在数组上调用`.pop()` ,并将其分配给`removedFromMyArray` 。
## 扰流板!代码解决方案
```javascript
var removedFromMyArray = myArray.pop();
=======
Remove the last element of an array with the pop() method, like so:
```
JavaScript的 var arr = \[1,2,3,4,5\]; arr.pop; //这摆脱了5
\`\`\`