How to test if a Javascript Array Is empty

Need to test if a javascript array is empty? Here is a little trick I found online. I was assuming that there was a some sort of built in function to test if the array but not so.   The trick is to check if the length of  the array is less than 1.

 

For example

if (theTestArray.length < 1)
alert (‘Array Is Empty’);

 

 

Source:http://bytes.com/topic/javascript/answers/90314-check-if-array-empty

Comments are closed.