1if (typeof array !== 'undefined' && array.length === 0) {
2 // the array is defined and has no elements
3}
4
1if (array === undefined || array.length == 0) {
2 // array empty or does not exist
3}
4
1if (Array.isArray(array) && array.length) {
2 // array exists and is not empty
3}