Categories
JavaScript Answers

How to remove last item from array with JavaScript?

Spread the love

To remove last item from array with JavaScript, we use the pop method.

For instance, we write

const fruit = ["apple", "orange", "banana", "tomato"];
const popped = fruit.pop();

to call fruit.pop to remove the last element in fruit and return it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *