JavaScript Answers

How to empty an array in JavaScript?

Spread the love

To empty an array in JavaScript, we set it to an empty array.

For instance, we write

let arr1 = ["a", "b", "c", "d", "e", "f"];
arr1 = [];

to assign the arr1 array to an empty array to empty the array.

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 *