--- In firstname.lastname@example.org
, "Felix E. Klee" <felix.klee@...> wrote:
> On Fri, Sep 7, 2012 at 1:21 PM, Tom Worster <fsb@...> wrote:
> > this is just JSLint saving you time in detecting an ES5 strict mode
> > error
> > see http://is.gd/WCXyRm
> Thanks for the link. I now read the article, and I understand that
> JSLint is just warning about a strict mode error. However, I do not
> understand why "function f()" is treated differently than "var f =
> function ()". Aren't the two statements equivalent? Or am I missing
There were famous websites that were depending on having functions with -this- bound to the global object, who then put 'use strict' on the code. That code failed in ES5 browsers but passed JSLint.
The difficulty for JSLint is that strict mode's operation on -this- is dynamic, but JSLint's analysis is static. How how could I reliably distinguish the case where -this- is used properly in a method from where -this- is used improperly to bind the global object.
My observation was that competent programmers always used function expressions to produce methods, and that incompetent programmers always used the statement form to bind the global object.
So when you specify strict mode, JSLint expects you to write like a competent programmer. I know that is a burden for some of you, but that's the best I can do.