W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 数组方法</h1> <h2>slice()</h2> <p>此例从数组元素 1(“Orange”)开始切出数组的一部分:</p> <p id="demo"></p> <script> var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"]; var citrus = fruits.slice(1); document.getElementById("demo").innerHTML = fruits + "<br><br>" + citrus; </script> </body> </html>