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

Re: assume a browser doesn't imply global window object

Expand Messages
  • Douglas Crockford
    ... Write onload = function (e) {...}; instead. The window is superfluous. ... Because global variables are evil, and window is the container of all global
    Message 1 of 4 , May 7, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Arthur Blake <arthur.blake@...> wrote:
      >
      > /*jslint browser: true*/ window.onload = function () {
      > document.getElementById("hello").appendChild(document.createTextNode("world"));
      > };

      Write

      onload = function (e) {...};

      instead. The window is superfluous.

      > Why does Assume a browser option allow document, but not window?

      Because global variables are evil, and window is the container of all global variables. Dependence on global variables introduces unreliability, insecurity, and weakness. You don't want superfluous badness in your code, do you?
    Your message has been successfully submitted and would be delivered to recipients shortly.