Expert Developer JavaScript Question: Download Expert JavaScript Developer PDF

Explain what is pop()method in JavaScript?

Tweet Share WhatsApp

Answer:

The pop() method is similar as the shift() method but the difference is that the Shift method works at the start of the array. Also the pop() method take the last element off of the given array and returns it. The array on which is called is then altered.
Example:
var cloths = ["Shirt", "Pant", "TShirt"];
cloths.pop();
//Now cloth becomes Shirt,Pant

Download Expert JavaScript Developer PDF Read All 150 Expert JavaScript Developer Questions
Previous QuestionNext Question
What is event bubbling, and why is it beneficial to use?How can I set up my own JavaScript error handler?