isEmpty() - Check if Object is Empty


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

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.