Home » JavaScript Array pop() Method

JavaScript Array pop() Method

by Online Tutorials Library

JavaScript Array pop() method

The JavaScript array pop() method removes the last element from the given array and return that element. This method changes the length of the original array.

Syntax

The pop() method is represented by the following syntax:

Return

The last element of given array.

JavaScript Array pop() method example

Let’s see some examples of pop() method.

Example 1

Here, we will pop an element from the given array.

Test it Now

Output:

Orginal array: AngularJS,Node.js,JQuery  Extracted element: JQuery  Remaining elements: AngulaJS,Node.js  

Example 2

In this example, we will pop all the elements from the given array.

Test it Now

Output:

Extracted element: JQuery  Extracted element: Node.js  Extracted element: AngulaJS  

Next TopicJavaScript Array

You may also like