Slice-1

 

JavaScript slice function is used to extract array from start index parameter to end index parameter. See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <script> var vegs = ["Tomato", "Patato", "Lemon", "Cheese", "Carrot"]; var result= vegs.slice(1, 4); document.write(result); </script> </body> </html>
Output