Re:Finally someone makes sense of JavaScript's this keyword
by masklinn on Saturday April 23, 2011 @11:24AM
(#2476964)
> Another way is jQuery.proxy()
Or the numerous ``bind`` functions and methods (which do the same thing).
In fact, ES5's Function prototype even grew a ``bind`` method[0], which is used to partially apply a function (both to bind it to a ``this`` and to bind it to an arbitrary number of arguments).
Some libraries (e.g. underscore) also have a shortcut to bind all methods of an object (or only a subset of those)[1], handy when using methods as event or deferred callbacks
Or the numerous ``bind`` functions and methods (which do the same thing).
In fact, ES5's Function prototype even grew a ``bind`` method[0], which is used to partially apply a function (both to bind it to a ``this`` and to bind it to an arbitrary number of arguments).
Some libraries (e.g. underscore) also have a shortcut to bind all methods of an object (or only a subset of those)[1], handy when using methods as event or deferred callbacks
[0] https://developer.mozilla.org/en/JavaScript/Reference/Global...
[1] http://documentcloud.github.com/underscore/#bindAll