Javascript array pop() method removes the last element from an array and returns that element.
Its syntax is as follows −
array.pop();
Returns the removed element from the array.
Try the following example.
<html> <head> <title>JavaScript Array pop Method</title> </head> <body> <script type="text/javascript"> var numbers = [1, 4, 9]; var element = numbers.pop(); document.write("element is : " + element ); var element = numbers.pop(); document.write("<br />element is : " + element ); </script> </body> </html>
element is : 9 element is : 4