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

Re: new Something();

Expand Messages
  • Douglas Crockford
    ... new is used to construct new instances of objects. It should not be used for side effects. The next edition will downgrade to a warning.
    Message 1 of 5 , Apr 28 10:24 AM
      --- In jslint_com@yahoogroups.com, "stepan.reznikov"
      > new Something();

      > Could you please explain why it's bad?
      > And why JSLint stops on this error and is unable to continue?


      new is used to construct new instances of objects.
      It should not be used for side effects.

      The next edition will downgrade to a warning.
    • Arthur Blake
      ... Any idea when this will be done? Personally, I would prefer that there be a jslint flag to control this behavior (something like Tolerate new statement
      Message 2 of 5 , Aug 31, 2009
        On Tue, Apr 28, 2009 at 1:24 PM, Douglas Crockford<douglas@...> wrote:
        > The next edition will downgrade to a warning.

        Any idea when this will be done? Personally, I would prefer that
        there be a jslint flag to control this behavior (something like
        "Tolerate new statement with side effects"), as there are several
        major libraries where the use of this pattern is routine. YUI and
        ExtJS are examples:

        // YUI example. A key listener

        // look for ESC pressed to cancel change
        new YAHOO.util.KeyListener(this.editInputField,{keys:27},
        {fn:function(c,e){
        this.cancelFieldChange();
        YAHOO.util.Event.stopEvent(e[1]);},
        scope:this,correctScope:true} ).enable();

        // ExtJS example. A viewport
        new Ext.Viewport({
        hideBorders: true,
        layout:'border', ......


        On Tue, Apr 28, 2009 at 1:24 PM, Douglas Crockford<douglas@...> wrote:
        >
        >
        > --- In jslint_com@yahoogroups.com, "stepan.reznikov"
        >> new Something();
        >
        >> Could you please explain why it's bad?
        >> And why JSLint stops on this error and is unable to continue?
        >
        > new is used to construct new instances of objects.
        > It should not be used for side effects.
        >
        > The next edition will downgrade to a warning.
        >

        >
      • douglascrockford
        ... Now.
        Message 3 of 5 , Aug 31, 2009
          --- In jslint_com@yahoogroups.com, Arthur Blake <arthur.blake@...> wrote:
          >
          > On Tue, Apr 28, 2009 at 1:24 PM, Douglas Crockford<douglas@...> wrote:
          > > The next edition will downgrade to a warning.
          >
          > Any idea when this will be done?

          Now.
        • Arthur Blake
          Thanks for the quick service. But what do you think about making an option for it like I proposed? If not, what do you suggest for the use cases I presented?
          Message 4 of 5 , Aug 31, 2009
            Thanks for the quick service. But what do you think about making an
            option for it like I proposed?
            If not, what do you suggest for the use cases I presented? Currently
            I'm left with having to create a var that I never use, just to make
            jslint not complain about that pattern...
            And I'm not in control of the libraries I'm using so I can't just
            change the usage pattern.

            On Mon, Aug 31, 2009 at 12:43 PM, douglascrockford<douglas@...> wrote:
            >
            >
            > --- In jslint_com@yahoogroups.com, Arthur Blake <arthur.blake@...> wrote:
            >
            >>
            >> On Tue, Apr 28, 2009 at 1:24 PM, Douglas Crockford<douglas@...> wrote:
            >> > The next edition will downgrade to a warning.
            >>
            >> Any idea when this will be done?
            >
            > Now.
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.