Posted By

jlizarraga on 09/02/09


Tagged

javascript object empty


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jsluv
vali29
guido


isEmpty() - Check if Object is Empty


 / Published in: JavaScript
 

Use this function to test whether or not a Javascript object is empty.

  1. function isEmpty(obj) {
  2. for(var prop in obj) {
  3. if(obj.hasOwnProperty(prop))
  4. return false;
  5. }
  6. return true;
  7. }

Report this snippet  

You need to login to post a comment.