javascript check if array is empty
snippet in javascript

javascript check if array is empty

user2021

if (typeof array !== 'undefined' && array.length === 0) {
    // the array is defined and has no elements
}

javascript check if array is empty

user9051

if (array && !array.length) {
    // array is defined but has no element
}

javascript how to check if array is empty

user8136

array.length