Loading ...
Sorry, an error occurred while loading the content.

Re: console read only

Expand Messages
  • pauanyu
    ... This whole thread has spiraled out of control. Here s the simple answer: If you use (console === undefined), and console has not been declared, it will
    Message 1 of 18 , Jul 10 1:48 PM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "sandyhead25" <austin.cheney@...> wrote:
      >
      > Why would you use
      > typeof(console) === "undefined"
      > instead of
      > console === undefined
      > which should be the same thing, but faster?
      >

      This whole thread has spiraled out of control. Here's the simple answer:

      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.
    Your message has been successfully submitted and would be delivered to recipients shortly.