Possible Duplicate: Detecting an undefined object property in JavaScript javascript undefined compare
H
You can use shorthand technique to check whether it is undefined or null
function A(val) { if(val || "") //do this else //do this }
hope this will help you