Pop-1

 

JavaScript pop is use to remove the last element from the array. See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="removeElement()">Remove the last element</button> <p id="sample"></p> <script> var fishName= ['angel', 'clown', 'mandarin', 'sturgeon']; document.getElementById("sample").innerHTML = fishName; function removeElement() { fishName.pop(); document.getElementById("sample").innerHTML = fishName; } </script> </body> </html>
Output