What does the pop() method do to a JavaScript array?

  • Removes the last element
  • Removes the first element
  • Adds an element to the end
  • Adds an element to the beginning
The pop() method in JavaScript removes the last element from an array and returns that element. This operation reduces the length of the array by 1. It's the opposite of the push() method, which adds an element to the end of the array. pop() is useful for removing elements from the end of a stack-like structure.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *