JS:pop() Method

The JavaScript pop() method is to remove an element from the rear end of the array.

The pop() 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.

<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 item and output to console.