I am having a "Possible strict violation" warning from JSHint about the use of this
keyword. The OP of this question faced a similar issue (mentioned in the update), but I don't think anyone addressed the reason of it. My code is of the form:
foo.prototype = (function (){
"use strict";
function bar (barfoo) {
if(this.foobar === 0)
{
//do something
}
}
})();
In this case, JSHint complains about the use of this
keyword ("Possible strict violation"). However, the warning goes away if I change it to:
foo.prototype = (function (){
"use strict";
var bar = function (barfoo) {
if(this.foobar === 0)
{
//do something
}
}
})();
What is the reasoning behind this? I'd like to understand the reason instead of just using a function expression or /* jshint validthis: true */
to suppress it.
Thanks!