Return to Snippet

Revision: 51766
at October 4, 2011 03:58 by vaibhav011286


Initial Code
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..

Initial URL


Initial Description


Initial Title
detect any type of empty var in JS

Initial Tags


Initial Language
JavaScript