[JS] How to test if a variable is defined
// returns 1 if defined, 0 otherwise.
function isDefined(anObj) {
switch(typeof(anObj)) {
case "string": if(anObj != "") return 1; else return 0;
case "undefined": return 0;
case "object": if(anObj != null) return 1; else return 0;
default: return 0;
}
}