What is the pop()method in JavaScript? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the pop()method in JavaScript?

3rd Aug 2019, 9:42 AM
Deepak Thakur
3 Answers
+ 8
pop() method removes the last element from an array and returns that element. Example: var arr = [1, 2, 3, 4]; console.log( arr.pop() ); // 4 console.log( arr ); // 1,2,3
3rd Aug 2019, 9:45 AM
VEDANG
VEDANG - avatar
+ 1
Pop() is javaScript Array method which removes and returns the last Item of Array, it is opposite of push() method which adds new item to the array at end.
3rd Aug 2019, 1:32 PM
Mukhtar Mahamed
Mukhtar Mahamed - avatar