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

83Re: scope bug? catch (e) "e already defined"

Expand Messages
  • Re Miya
    Jun 16, 2008
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
      wrote:
      >
      > --- In jslint_com@yahoogroups.com, "Re Miya" <remiya_ws@> wrote:
      > > However I have stuck into another problem:
      > >
      > > var test = function(){
      > > this.pub_function = function(){
      > > pvt_fn();
      > > }
      > > var pvt_fn = function(){
      > > // Code here
      > > }
      > > }
      > >
      > > JsLint reports pvt_fn as a global reference. Is this normal?
      >
      > Move the definition of pvt_fn before the pub_function that uses it.
      >
      That really makes sense.
      Up to now I have been putting the private fns at the end like this
      var test = function(){
      this.pub_function = function(){
      pvt_fn();
      }
      //------------ PRIVATE METHODS -----------//
      var pvt_fn = function(){
      // Code here
      }
      }
      Now I will put them at the top

      var test = function(){
      //------------ PRIVATE METHODS -----------//
      var pvt_fn = function(){
      // Code here
      }

      //------------ PUBLIC METHODS -----------//
      this.pub_function = function(){
      pvt_fn();
      }
      }

      Thank you!
    • Show all 7 messages in this topic