js 数组pop方法
JavaScript中的数组pop()方法用于删除并返回数组的最后一个元素。在调用pop()方法后,数组的长度会减少1。
语法:
array.pop()
参数:
该方法不接受任何参数。
返回值:
返回被删除的元素。
示例:
const fruits = ['apple', 'banana', 'orange'];
const lastFruit = fruits.pop(); // 'orange'
console.log(fruits); // ['apple', 'banana']
console.log(lastFruit); // 'orange'
原文地址: http://www.cveoy.top/t/topic/ba6z 著作权归作者所有。请勿转载和采集!