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

549Re: [jslint] Re: Undefined variable

Expand Messages
  • Nagy Endre
    May 29, 2009
      Yes, this resolve the problem. I thought that a line such
      var test
      will drop the previous value of the test if this was defined/set somewhere globally.
      Anyway, thanks for all the answers - was solved a lot of confusion for me.

      --- On Fri, 5/29/09, Jakob Kruse <kruse@...> wrote:

      From: Jakob Kruse <kruse@...>
      Subject: Re: [jslint] Re: Undefined variable
      To: jslint_com@yahoogroups.com
      Date: Friday, May 29, 2009, 10:12 AM

















      Hasn't this all gotten a little far from the original problem?



      The way I understood it, it had to do with "namespaces" . If you have two javascript files that both declare some functionality in the same namespace, and you're not sure if you'll be using one file, the other file, or both files (or you are sure but all three cases exist in various parts of the application) , then you do need "special tricks" (i.e. not just creating the namespace and putting stuff in it) to avoid the contents of the second file removing everything declared by the first.



      The simple trick is to start both files like this:



      var Namespace = Namespace || {};



      No need to check if Namespace has already been declared, just use the rather powerful 'or' operator.



      /Jakob
























      [Non-text portions of this message have been removed]
    • Show all 25 messages in this topic