PHP empty in javascript
Snippet
Posted by kitt at 18:39 on 19 September 2009
Equivalent of PHP's empty in javascript
function empty (mixed_var) { // version: 909.322 // discuss at: http://phpjs.org/functions/empty var key; if (mixed_var === "" || mixed_var === 0 || mixed_var === "0" || mixed_var === null || mixed_var === false || mixed_var === undefined ) { return true; } if (typeof mixed_var == 'object') { for (key in mixed_var) { return false; } return true; } return false; }
Source: