Array.pop
Array.pop
功能
删除并返回数组最后一个元素。
语法
array.pop()
参数
无参数。
返回值
| 类型 | 说明 |
|---|---|
| Any/Empty | 数组非空时返回被删除的元素;空数组返回 Empty。 |
示例
items = [1, 2, 3] result = items.pop() // 输出:3 print result
注意事项
- 该方法会修改原数组。
删除并返回数组最后一个元素。
array.pop()
无参数。
| 类型 | 说明 |
|---|---|
| Any/Empty | 数组非空时返回被删除的元素;空数组返回 Empty。 |
items = [1, 2, 3] result = items.pop() // 输出:3 print result