Javascript examples for Array:pop
The pop() method removes and returns the last element of an array.
This method changes the length of an array.
None
removed array item.
The following code shows how to Remove the last element of an array:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> var fruits = ["a","b","c","d","e"]; document.getElementById("demo").innerHTML = fruits; function myFunction() {// w w w .j a v a 2 s . c om fruits.pop(); document.getElementById("demo").innerHTML = fruits; } </script> </body> </html>