源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p>这个slice() 示例从数组元素2("Lemon")中取出数组的一部分 :</p> <p id="demo"></p> <script> var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"]; var citrus = fruits.slice(2); document.getElementById("demo").innerHTML = fruits + "<br>" + citrus; </script> </body> </html>
运行结果