Occasionally I learn new things about Javascript:
`typeof foo`, when `foo` is a variable-name-looking-thing, doesn't actually treat `foo` as a normal expression (i.e., you'd expect `foo` to be evaluated and then its valuation inspected for type. That's what happens when you do `typeof (1 + 2)`). Rather, variable-name-looking-things are treated specially and, specifically, if they are not defined, `typeof foo` returns `undefined` (even though `foo` is not an extant variable with any value, including the value `undefined`).
This means:
1) you can use `typeof` to check if a variable exists in a dynamic context like the browser where new global variables could be defined at any time, and
2) in a `"use strict"` context, `typeof` will let through fat-fingered variables. I.e., this raises a ReferenceError: `let foo = 1; if (foi /*sic*/ === 1) bar();`, but this just always evaluates to false: `let foo = 1; if (typeof foi /*sic*/ !== undefined) bar();`
@hamptos You are in a maze of twisty social networks, all alike.
Information Scientist / Tech Company CTO