check if element is empty javascript code example
Example 1: javascript check if array is empty
if (typeof array !== 'undefined' && array.length === 0) {
// the array is defined and has no elements
}
Example 2: js check if div is empty
if ($('#element').is(':empty')){
//do something
}
Example 3: javascript check if object is null or empty
if (typeof value !== 'undefined' && value) {
//deal with value'
};