javascript check if array is empty

JavaScript
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
}array.length
Source

Also in JavaScript: