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

Re: [jslint] Re: Implied global or hoisted var

Expand Messages
  • Michael
    ... beyond confusing if you have it also defined in the global scope. [Non-text portions of this message have been removed]
    Message 1 of 10 , Jul 28, 2010
    View Source
    • 0 Attachment
      On Wed, Jul 28, 2010 at 9:07 AM, bertbelder <bertbelder@...> wrote:

      >
      >
      > > You're making a bunch of assumptions about your code. In the future you
      > > might try to make some changes that will make your code wrong. Imagine in
      > > your example:
      > >
      > > (function outer() {
      > > var foo = function() {
      > > bar();
      > > };
      > >
      > > if (true) {
      > > return;
      > > }
      > >
      > > var bar = function() {
      > > };
      > >
      > > foo();
      > > })();
      > >
      > > Suddenly your variable does become global. JSLint recommends you define
      > all
      > > your variables at the top of each scope, so this kind of thing won't
      > happen.
      >
      > Erm, I don't see it. What becomes global then?
      >
      > You're right, I need more coffee. It becomes undefined due to hoisting, but
      beyond confusing if you have it also defined in the global scope.


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.