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) {
// array is defined but has no element
}
if(typeof array != 'undefined' && array.length > 0){
// array has elements
}
if (!Array.isArray(array) || !array.length) {
// array does not exist, is not an array, or is empty
// ⇒ do not attempt to process array
}
if(array.length > 0)
if (array === undefined || array.length == 0) {
// array empty or does not exist
}
if (typeof image_array !== 'undefined' && image_array.length > 0) {
// the array is defined and has at least one element
}
const isNotEmpty = arr => Array.isArray(arr) && arr.length > 0;
isNotEmpty([1, 2, 3]);
// Result: true
const isNotEmpty = arr => Array.isArray(arr) && arr.length > 0;
isNotEmpty([1, 2, 3]);
// Result: true
array.length = []