Consider this simple example:
"use strict";
var Foo = {
field: 0,
func: function () {
this.field = 4;
}
}
JSLint throws the error:
Unexpected 'this'. At the line "this.field = 4".
I've seem some questions here in StackOverflow asking for this, and in all the cases, the answer was just to enable the "Tolerate this" flag. However, I'm interested in why do the JSLint creators think the use of "this" is (or might lead to) an error.
Also, how would I implement member functions without the "this" keyword and without expecting the user to pass the instance as the first argument?
EDIT Maybe I didn't make myself clear enough in that this question, despite looking similar doesn't have an answer to what I'm asking: JSLint Error: Unexpected 'this'
The problem with that question is not the question itself but rather the answers it got. Note how the accepted answer is: "My suggestion is: tell JSLint to shut up". And I specifically say in my post that this is not a valid answer to me, as I want to understand why is the use of this forbidden by JSLint, not how to avoid that error.