The pop() method removes the last element of an array, and returns that element.
The pop() method removes the last element of an array, and returns that element.
This method changes the length of an array.
To remove the first element of an array, use the shift() method.
pop() method is using the array as stack.
array.pop()
None |
---|
Any type, representing the removed array item.
The array item can be a string, a number, an array, a boolean, or any other object types stored in an array.
Remove the last element of an array:
var myArray = ["XML", "Json", "Database", "Mango"]; console.log( myArray);/*from w w w. j a v a 2 s . co m*/ var r = myArray.pop(); console.log( myArray ); console.log( r );