Check if an array is empty in JavaScript

JavaScript Sep 7, 2022

In JavaScript, it's very easy to check if an array is empty. The following code will do it:

const arr = [] if (arr.length === 0) { console.log("Array is empty") }

And that's it!

Tags