1if (Array.isArray(array) && array.length) {
2 // array exists and is not empty
3}
1arr = []; // set array=[]
2
3//function
4const empty = arr => arr.length = 0;
5//example
6var arr= [1,2,3,4,5];
7empty(arr) // arr=[]
1// define Array
2let list = [1, 2, 3, 4];
3function empty() {
4 //empty your array
5 list = [];
6}
7empty();
8
1if (typeof array != "undefined" && array != null && array.length != null && array.length > 0) {
2 // array exists and is not empty
3}
4