To check if an array is empty or exists with JavaScript, we use the Array.isArray method and the array’s length property.
For instance, we write
if (Array.isArray(array) && array.length) {
// ...
}
to check if array is an array with Array.isArray.
And then we use array.length to check if it’s bigger than 0 to check if it’s filled with content.