/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function empty(a) { if (a === "" || a === 0 || a === null || a === 'null' || a === 'undefined' || a === !1 || typeof a === "undefined") return !0; if (typeof a === "object") if (a instanceof Array) return a.length === 0; else { for (var b in a) return !1; return !0 } if (typeof a === "string") return a.length === 0 } //it detects any type of empty var in JS like array, object, string, number etc..
Comments
