if (typeof array !== 'undefined' && array.length === 0) { // the array is defined and has no elements }
if (array && !array.length) { // array is defined but has no element }
arr = []; // set array=[] //function const empty = arr => arr.length = 0; //example var arr= [1,2,3,4,5]; empty(arr) // arr=[]
var colors = ["red","blue","green"]; colors = []; //empty the array
var colors=[]; if(!colors.length){ // I am empty }else{ // I am not empty }
// Variable array for a wider scope: var arrayName = []; // Local scope variable array: let arrayName = [];
if (typeof image_array !== 'undefined' && image_array.length > 0) { // the array is defined and has at least one element }
Array.isArray(emptyArray) && emptyArray.length
array.length = []
// define Array let list = [1, 2, 3, 4]; function empty() { //empty your array list = []; } empty();