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

576 B
Raw Blame History

title localeTitle
Manipulate Arrays With pop() 使用pop操作数组

使用pop操作数组

问题解释

摆脱数组中的最后一个元素。然后,将该骑行元素分配给removedFromMyArray

提示1

在数组上调用.pop() ,并将其分配给removedFromMyArray

扰流板!代码解决方案

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

```