JavaScript verifique se a matriz está vazia
if (typeof array !== 'undefined' && array.length === 0) {
// the array is defined and has no elements
}
Code Hero
if (typeof array !== 'undefined' && array.length === 0) {
// the array is defined and has no elements
}
if (array === undefined || array.length == 0) {
// array empty or does not exist
}
if(array && array.length){
// not empty
} else {
// empty
}