Home
<!DOCTYPE html> <html> <body> <h1>Demo: Remove Last Element from an Array in JavaScript</h1> <p id="p1"></p> <p id="p2"></p> <p id="p3"></p> <script> let cities = ["Mumbai", "New York", "Paris", "Sydney"]; document.getElementById("p1").innerHTML = cities; let removedCity = cities.pop(); document.getElementById("p2").innerHTML = cities; document.getElementById("p3").innerHTML = removedCity; </script> </body> </html>
Result: