DEV Community

Discussion on: 💡 How to check if a variable is undefined in JS

Collapse
 
mgtitimoli profile image
Mauro Gabriel Titimoli • Edited

The best option when you don't know something about JS is check for it in the spec...
ecma-international.org/ecma-262/10...

UnaryExpression: typeof UnaryExpression

  1. Let val be the result of evaluating UnaryExpression.
  2. If Type(val) is Reference, then a. If IsUnresolvableReference(val) is true, return "undefined".