How to Empty an Array With JavaScript

Learn how to empty an array with JavaScript.

Emptying an array with JavaScript could not be more simple. Let’s say you have an array with a list of exercises:

let exerciseList = ['squat' , 'deadlift' , 'push-up', 'pull-up']  

Use console.log(exerciseList) to print out your list of exercises and confirm that it works.

Now to empty your array, simply run the following:

exerciseList.length = ''

Now when you console.log(exerciseList) again, you’ll get an empty array: