pop()
-该方法可以删除数组的最后一个元素,并将被删除的元素作为返回值返回
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
arr = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
];
arr.pop();
alert(arr);
</script>
</body>
</html>
返回值:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
arr = [
[1, 2, 3],
[3, 4, 5],
[5, 6, 7],
];
var result = arr.pop();
alert(arr);
console.log("result=" + result);
</script>
</body>
</html>