Closed rossgrambo closed 1 month ago
typeof works great to see if a variable was declared. However the ? operator does not work when the variable was not declared.
typeof
?
For example:
> bad?.foo Uncaught ReferenceError: bad is not defined > bad = undefined undefined > bad?.foo undefined
vs
> typeof bad 'undefined' > bad = undefined undefined > typeof bad 'undefined'
typeof
works great to see if a variable was declared. However the?
operator does not work when the variable was not declared.For example:
vs