- Substituting an existing array with a new array.
- Setting an array length prop to 0.
- Splice the whole array.
Substituting an existing array with a new array
dark = ['jonas', 'martha', 'claudia'] console.log(dark) console.log('After substituting array with empty array') dark =  console.log(dark)
[ 'jonas', 'martha', 'claudia' ] After substituting array with empty array 
The dark = [ ] assigns a reference to a new array to a variable. In contrast, any other references are unaffected, which means that references to the contents of a previous array are still kept in the memory, leading to memory leaks.
Setting an array length to 0
To clear an array, convert the array length to 0. This way, array can’t have a single item, and it will automatically be cleared. It removes each item in the array, which does hit other references.
In other words, if you have two references to the same array (a = [11, 21, 46]; a2 = a;), and you delete the array’s contents using an array.length = 0, both references (a and a2) will now point to the same empty array.
let data = [11, 21, 46]; let set = [11, 21, 46]; let data2 = data; let set2 = set; data = ; set.length = 0; console.log(data, set, data2, set2);
  [ 11, 21, 46 ] 
Empty array by Splice the whole array
let data = [11, 21, 46]; data.splice(0, data.length) console.log(data)
To use the splice() method, passing first argument as 0 and array length as the second parameter. This will return the copy of the original elements, which may be handy for some scenario but it will remove all items from the array and will clean the original array.