How to empty an array in JavaScript
In JavaScript, there are multiple ways available to remove all elements of an array. The simplest method is to set the array's length property value to 0.
*Another way to remove all elements of an array is by assigning an empty array to the original variable
*The splice() method is yet another way to empty an array in JavaScript
*You can also add a new method to Array's prototype and use it whenever you want to clear an array: