DEV Community

Sujit Kar
Sujit Kar

Posted on • Edited on

How to check an Array is empty or not in Javascript?

There is a very simple technique to check whether an array is empty or not.

const arr = [];
if(arr.length === 0){
 console.log("Array is empty");
}
else{
 console.log("Array is not empty");
}
Enter fullscreen mode Exit fullscreen mode

Get in touch with me.

Thanks!!!
@sujitkar1195

Top comments (0)