Possible Duplicate: Detecting an undefined object property in JavaScript javascript undefined compare
H
I know I am late to answer the function but jquery have a in build function to do this
if(jQuery.type(val) === "undefined"){ //Some code goes here }
Refer jquery API document of jquery.type https://api.jquery.com/jQuery.type/ for the same.