数组.pop()
方法从数组中删除最后一个元素,并返回该元素的值。
语法:
arr.pop()
示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
<script>
let arr = ['red', 'blue', 'green']
arr.pop()
console.log(arr)
</script>
</body>
</html>
控制台输出: