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 JavaScript Subscribe to our newsletter Get the latest posts delivered right to your inbox. Your email address Subscribe Now check your inbox and click the link to confirm your subscription. Please enter a valid email address Oops! There was an error sending the email, please try later. Recommended for you JavaScript Securing an Express.js app with Helmet Securing your Express.js app is important. Learn how to do it in this guide. 12 days ago JavaScript How to reverse an array in JavaScript Learn how to reverse an array in JavaScript 22 days ago JavaScript Generating secure session tokens Learn how to generate secure session tokens 23 days ago
JavaScript Securing an Express.js app with Helmet Securing your Express.js app is important. Learn how to do it in this guide. 12 days ago
JavaScript How to reverse an array in JavaScript Learn how to reverse an array in JavaScript 22 days ago