Wednesday, October 26, 2005

JavaScript " null " and "undefined"

JavaScript :

I need to check if every object is null or undefined - if neither, I must proceed with the validation. Else, Javascript throws ugly errors on the screen.

Check for null

if(object!=null) // the object isn't null.

Check for undefined

if(object) // the object is not 'undefined'