I was going through this article http://dev.opera.com/articles/view/objects-in-javascript/
where I read “‘this’ keyword doesn’t always refer to the object on which a method is defined, but instead can change based on specific contexts.”
I couldn’t find any example in which ‘this’ does not refer to the object on a method is defined….please gimme an example if possible
I was going through this article http://dev.opera.com/articles/view/objects-in-javascript/ where I read ‘this’ keyword doesn’t always
Share
There are many way to change context. jsfiddle
using bind: (not supported by older IE browsers (IE < 9))
Using apply or call.