RSS | Archive | Random | E-mail

About

Hi, I'm Christian Castelli, a 28 years old italian programmer located in Pisa (Italy). Here I post small snippets of code which can be useful in my work.

Links

Codepuzzling main site
Development site
ByteStrike italian blog
Follow me on Twitter

My Life Style

while(passion) {
  try {
    myLife.run();
  }catch(LifeExceptions) {  
    stronger++;
    continue;
   }
}

Following

1 July 09

[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;
   }
}

Comments (View)
  1. andreaolivato reblogged this from codepuzzling
  2. codepuzzling posted this
blog comments powered by Disqus
Themed by Hunson. Originally by Josh