Removing the Last Element from Arrays with pop in Javascript


Remove the last item from an array.

Source Code

let fruits = ["Apple", "Banana", "Orange"];
let lastFruit = fruits.pop();
console.log(fruits); // ["Apple", "Banana"]
console.log(lastFruit); // "Orange"
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments