Array.pop Last updated: 22. Jul 2024
The pop() method removes the last element from an array and returns that element. This method changes the length of the array.
Parameters
This function takes no parameters
Returns
Returns the element that was removed from array.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#{
// Init an array with two items
var arr = ["one", "two"];
// Remove last item with "pop"
arr.pop();
// Output the array to screen
write(JSON.stringify(arr));
}#
Output
The #JS code above produces the output shown below:["one"]