array js empty code example
Example 1: js how to check is array empty es6
var colors=[];
if(!colors.length){
// I am empty
}else{
// I am not empty
}
Example 2: javascript empty array
arr = []; // set array=[]
//function
const empty = arr => arr.length = 0;
//example
var arr= [1,2,3,4,5];
empty(arr) // arr=[]
Example 3: javascript how to check if array is empty
if(array.length > 0)
Example 4: js check if array is empty
if (typeof image_array !== 'undefined' && image_array.length > 0) {
// the array is defined and has at least one element
}
Example 5: empty array javascript
// set array
arr = [1,2,4];
// empty array
arr = [];