Sometimes it’s difficult to find an easy answer to common coding questions. Because
Google ignores most punctuation, even the most exact queries fail to produce
relevant results. Questions about the nature and value of
a particularly thorny problem, since “this” is about as common a word as you can find.
this depends entirely
on a function’s context, and can even be overridden depending on how a function is
In anonymous functions, the value of
thisrefers to the anonymous function itself, and not the calling scope. However, the nature of closures allows the anonymous function to still refer to the calling object.
The above rule is demonstrated with the following nodejs code:
1 2 3 4