Master AI & Build your First Coding Portfolio with SkillReactor | Sign Up Now

Lesson 7 - Basic Array Operations

7.2 Pop

The function pop() returns the last element of an array and deletes it. For example:

let fruits = ['Apple', 'Banana', 'Orange'];
console.log(fruits.pop()); // Output: Orange
console.log(fruits);

Here, fruits.pop() returns the last value of the array fruits and then removes it from the array.

Try to pop() another item from the array fruits: