Possible Duplicate:
variable === undefined vs. typeof variable === “undefined”
Assuming that undefined has not been tampered with, are the following equivalent?
typeof a === 'undefined'
and
a === undefined
?
[The reason I ask is because the author of Parsley.js seems to love writing 'undefined' !== typeof someExpression.]
These two approaches are almost the same, except one:
typeofwon’t raiseReferenceError: a is not definedin case ifavariable was not defined as a variable.Say,
typeofapproach is just more fool-proof.