JS: Array.prototype.pop

By Xah Lee. Date: . Last updated: .

myArray.pop()

Remove and return the last item.

myArray is modified.

If myArray is empty, return undefined.

const ar = [3,4];

console.log( ar.pop() ); // 4

console.log( ar ); // [ 3 ]

[see JS: Array.prototype.push]

Reference

ECMAScript® 2016 Language Specification#sec-array.prototype.pop

Array Topic

  1. JS: Array Basics
  2. JS: Understand JS Array
  3. JS: Create Array
  4. JS: Sparse Array
  5. JS: Array-Like Object
  6. JS: Array How-To

  1. JS: Array Object
  2. JS: Array.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth