pop

Remove and return the last element from an array.

listget and remove last value from
JavaScript
(method) Array.pop(): T;
Python
(method) Array.pop(): T

The last element in the array is removed, so the array becomes smaller by one element.

If you have an array with 4 numbers, like 1, 2, 3, and 4, you remove the last number from the array by popping it off of the end. To pop the number from the array in blocks, do this:

1234array ofthoseNumbersget and remove last value fromsetlastNumbertosetthoseNumbersto

Returns

  • The last element in the array.

Example

Clean out your junk drawer but check if the scissors are in there. Do this by removing them from your list items in the drawer.

"paper clip""pencil""notepad""glue""scissors""screw driver"array ofjunklength of array0‏>junkget and remove last value from"scissors"=truesetfoundtoifthenwhiledosetjunktoon start

See also

push, shift