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