Re: console read only
- --- In firstname.lastname@example.org, "sandyhead25" <austin.cheney@...> wrote:
>This whole thread has spiraled out of control. Here's the simple answer:
> Why would you use
> typeof(console) === "undefined"
> instead of
> console === undefined
> which should be the same thing, but faster?
If you use (console === undefined), and console has not been declared, it will throw a ReferenceError.
If you use (typeof console === "undefined"), and console has not been declared, it will *not* throw a ReferenceError.
There IS a difference between an undeclared variable and an undefined variable. A variable can be declared but undefined. An undeclared variable will throw a ReferenceError, but an undefined variable will not.
That is why it is better to use typeof, because it will not throw a ReferenceError for undeclared variables.