JS:pop() Method

The JavaScript<span style="color:#cf2e2e" class="tadv-color"> pop()</span> method is to remove an element from the rear end of the array.


The <span style="color:#cf2e2e" class="tadv-color">pop()</span> method deletes just one element from the array. The element is topmost element of the array.


In this example, we will pop() just one element from the array and store that element in a variable and display the deleted entry.

  var fruits = ['apple','orange','grapes'];
  var item = fruits.pop()
//output is "grapes"

The script will remove the last element of the array which is “grapes“. It is stored in the variable <span style="color:#cf2e2e" class="tadv-color">item </span>and output to console.


Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.