typeof is an operator , not a function, and returns a string; therefore, do not use parentheses and do compare it with a string.
When comparing things, avoid type coercion unless you need it (i.e. use === not == ).
if (typeof myvar === 'undefined') {
Quentin
source share