Possible Duplicate:
Is there a standard function to check for null, undefined, or blank variables in JavaScript?
What is the best way to check for the undefined type in JavaScript? I know one way to check is by using typeOf, but I have to check for it in lots of places; is there a shorter or better way to do this?
I tried a few ways but didn’t succeed:
alert(undefined === "undefined");
alert(undefined || "defined");
Nothing new for you:
The problem of using
val || "defined"is that “defined” will be returned in casevalisnull,undefined,0,falseor"".