Expert Developer JavaScript Question: Download Expert JavaScript Developer PDF
Explain what is pop()method in JavaScript?
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
Example:
var cloths = ["Shirt", "Pant", "TShirt"];
cloths.pop();
//Now cloth becomes Shirt,Pant
Previous Question | Next Question |
What is event bubbling, and why is it beneficial to use? | How can I set up my own JavaScript error handler? |