Reputation: 1
What is the difference between these two statements?
if (typeof errorMessage !== undefined)
{}
and
if (typeof (errorMessage) !== undefined)
{}
Upvotes: 0
Views: 176
Reputation: 943579
One of them has a pair of entirely superfluous parentheses.
The difference between typeof foo
and typeof (foo)
is the same as the difference between 1 + 1
and (1) + (1)
.
An an aside, the typeof
operator will give you a string, so you should be comparing to "undefined"
not undefined
.
Upvotes: 10