Posted By

dsoms on 04/15/11


Tagged

javascript empty


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

notturnale


Detect empty values in JavaScript


 / Published in: JavaScript
 

  1. function isEmpty(obj)
  2. {
  3. if (typeof obj == 'undefined' || obj === null || obj === '') return true;
  4. if (typeof obj == 'number' && isNaN(obj)) return true;
  5. if (obj instanceof Date && isNaN(Number(obj))) return true;
  6. return false;
  7. }

Report this snippet  

You need to login to post a comment.