Check if array is empty in javascript


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. if (testarray.length <1) alert("array is empty");
  2.  
  3.  
  4. //or
  5.  
  6. if(A && A.length==0)
  7.  
  8. //or if you have other objects that A may be:
  9.  
  10. if(A && A.constructor==Array && A.length==0)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.