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

1386Implied global or hoisted var

Expand Messages
  • Bert Belder
    Jul 27, 2010
    • 0 Attachment
      When linting this code:

      (function outer() {
      var foo = function() {
      bar();
      };

      var bar = function() {
      };

      foo();
      })();

      JSLint gives me these warnings:

      Problem at line 3 character 5: 'bar' is not defined.
      Implied global: bar 3
      Unused variable: bar 1 outer

      I think all three warnings are wrong. Due to type hoisting the 'var bar'
      declaration applies to the entire scope of the 'outer' function, so foo()
      inherits 'bar' from 'outer'.

      Or am I missing something here?

      best regards,
      Bert
    • Show all 10 messages in this topic