JS - How to Check if Array is Empty or Null or Undefined or has 3 items
Hello dev's, today I'll show you how to check if array is empty or null or undefined or has 3 items using Pure JS. We all know that sometimes handling array is getting quite complex in our JS script code. And it is very important to handle each case in our JS code because one line of code can make whole site unstable. So todays tutorial is regarding handling array. So, let's get started.
So here we'll see 3 example which will cover all most all the known use cases array. So in the first array we'll see If an array is empty or not, And in the 2nd example we'll see if an array has 0 items or not. And in the third example we'll see if an array is undefined or not. And in the last example we'll see if an array is null or not. So let's start our coding. See the below conde snippets.
That's it for today. If you've any question, catch me in the comment section. Hope you'll enjoy through this tutorial. Thanks for reading :)
Preview may take a few seconds to load.
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Bold **double asterisks**
Three back ticks and then enter your code blocks here.
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
> type a greater than sign and start typing your quote.
You can add links by adding text inside of  and the link inside of (), like so:
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of , and the image URL inside of (), like so:
To add a divider you can add three dashes or three asterisks:
--- or ***