1arr = []; // set array=[]
2
3//function
4const empty = arr => arr.length = 0;
5//example
6var arr= [1,2,3,4,5];
7empty(arr) // arr=[]
1let list = [1, 2, 3, 4];
2function empty() {
3 //empty your array
4 list.length = 0;
5}
6empty();
7
1var arr1 = ['a','b','c','d','e','f'];
2var arr2 = arr1; // Reference arr1 by another variable
3arr1 = [];
4console.log(arr2); // Output ['a','b','c','d','e','f']
5