Am just a beginner in JavaScript and I found this keyword really difficult to understand for me. I know this depends on how the function is invoked.
The code is .
MyClass = function() {
this.element = $('#element');
this.myValue = 'something';
// some more code
}
MyClass.prototype.myfunc = function() {
this.element.click(function() {
});
}
new MyClass();
I just need to know what this denotes in this.element.click(function() {}
Does it denote Myclass? Please help me in understanding the use of this keyword in prototype functions in JavaScript.
Myclassis a constructor. When you create a new object from it usingnew,thisrefers to that new object.