Closed OliverSieweke closed 3 years ago
That's true. I just didn't care to delve into those weeds at that point.
Also, you shouldn't really ever use typeof
against a variable that you don't know if exists or not... except in one narrow corner case: when dealing with global variables that may or may not have been declared in other script files. This used to be a more common pattern, but the language is definitely moving away from it, so it's not a top-of-mind kind of thing anymore.
At best I might have noted this nuance in the appendix, but it just didn't feel weighty enough of an exception to get into.
Thanks!
Thanks for the clarifications! I hope the rest of the series is coming along well!
Please type "I already searched for this issue": I already searched for this issue.
Edition: (1st or 2nd) 2nd
Book Title: Scope & Closures
Chapter: Chapter 2: Illustrating Lexical Scope
Section Title: Undefined Mess
Problem: The Undefined Mess section states:
I believe that this sentence is not strictly correct. It is indeed safe to use undeclared variables in the case of
typeof
statements without causing aReferenceError
, as is actually shown in one of the provided examples:Thanks for making this material available. I very much appreciate the tone in the second edition!