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.

Advertisements

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.

Advertisements

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

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

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.

Advertisements

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.