1.

Explain the pop () method in JavaScript? Give an example of using the pop () method.

Answer»

The pop() method is similar to the shift() method, but the difference is that the Shift method works at the array’s start. The pop() method takes the last element off of the given array and returns it. The array on which it is called is then altered. 

Example: 

cloth = ["Shirt", "Pant", "TShirt"]; 

cloth.pop(); 

//Now cloth becomes Shirt,Pant



Discussion

No Comment Found

Related InterviewSolutions