W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 数组方法</h1> <h2>pop()</h2> <p>pop() 方法从数组中删除最后一个元素。</p> <p>pop() 方法的返回值是已删除的项目。</p> <p id="demo1"></p> <p id="demo2"></p> <p id="demo3"></p> <script> var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo1").innerHTML = fruits; document.getElementById("demo2").innerHTML = fruits.pop(); document.getElementById("demo3").innerHTML = fruits; </script> </body> </html>