删除数组中最后一个元素 - pop()
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 数组方法</h1>
- <h2>pop()</h2>
- <p>pop() 方法从数组中删除最后一个元素。</p>
- <p id="demo1"></p>
- <p id="demo2"></p>
- <script>
- var fruits = ["Banana", "Orange", "Apple", "Mango"];
- document.getElementById("demo1").innerHTML = fruits;
- fruits.pop();
- document.getElementById("demo2").innerHTML = fruits;
- </script>
- </body>
- </html>