To check if an array is empty in JavaScript, do this:
array.length === 0
.Here's how you do it:
const nonEmptyArray = [ 1, 2, 3 ];
const emptyArray = [];
console.log(nonEmptyArray.length === 0); // false
console.log(emptyArray.length === 0); // true