Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Extract All Elements from an Array beyond Specific Index</title> </head> <body> <script> var fruits = ["Apple", "Banana", "Mango", "Orange", "Papaya"]; document.write(fruits.slice(2) + "<br>"); // Prints: Mango,Orange,Papaya document.write(fruits.slice(-2) + "<br>"); // Prints: Orange,Papaya document.write(fruits.slice(2, -1)); // Prints: Mango,Orange </script> </body> </html>