

JavaScript Scope & "this" - jackfranklin
http://javascriptplayground.com/blog/2012/04/javascript-variable-scope-this

======
exDM69
If anyone ever wonders why Python has the explicit self-variable, this is the
answer. If you define a local class inside a method inside a class, you will
have two variables called "this" or "self" and it may be practical to refer to
both of them. Sometimes you see JavaScript with "var self = this;" or
something similar.

------
EvilTerran
That covers it nicely.

A couple of minor typos, though: You've got extraneous ")"s in the code-blocks
under "Local Scope" and "A word of Caution", and I think the one under "very
bad idea" needs the last line to be "})();" in place of just "});".

------
psquid
A good read, but a little disappointing that it didn't touch on the
(function(...) {...}).bind(this) approach to passing the parent "this" context
down the function tree, preferring instead to use an extra variable in the
form of "_this".

