源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p>slice() 示例从数组元素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>" + citrus; </script> </body> </html>
运行结果