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

Using "this" in constructor in strict mode

Expand Messages
  • s_lubowsky
    I just grabbed the latest jslint (8/3/11) and suddenly its complaining that using this is a constructor is a strict violation. I searched around a bit but
    Message 1 of 2 , Aug 5 8:36 AM
    • 0 Attachment
      I just grabbed the latest jslint (8/3/11) and suddenly its complaining that using "this" is a constructor is a strict violation. I searched around a bit but didn't see anybody talk about this. Is this a true violation? If so, what is the "correct" way to right it.

      For example linting the following code on www.jslint.com fails with Problem at line 3 character 5: Strict violation.
      this.foo = "foo";

      function TestThisInConstructor() {
      "use strict";
      this.foo = "foo";
      }

      Thanks
      Stephen
    • Douglas Crockford
      ... Thanks. Please try it now.
      Message 2 of 2 , Aug 5 3:58 PM
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "s_lubowsky" <slubowsky@...> wrote:
        > I just grabbed the latest jslint (8/3/11) and suddenly its complaining that using "this" is a constructor is a strict violation. I searched around a bit but didn't see anybody talk about this. Is this a true violation? If so, what is the "correct" way to right it.
        >
        > For example linting the following code on www.jslint.com fails with Problem at line 3 character 5: Strict violation.
        > this.foo = "foo";
        >
        > function TestThisInConstructor() {
        > "use strict";
        > this.foo = "foo";
        > }

        Thanks. Please try it now.
      Your message has been successfully submitted and would be delivered to recipients shortly.