Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Extract the Last Value from a JavaScript Array</title> </head> <body> <script> var fruits = ["Apple", "Banana", "Kiwi", "Mango", "Orange"]; // Extracting the last item var last = fruits.slice(-1)[0]; document.write(last); // Prints: Orange </script> </body> </html>