Using instance methods as callbacks for event handlers changes the scope of this
from \"My instance\" to \"Whatever just called the callback\"
Just adding to this that in ES6 because of arrow functions you shouldn't need to do this because they capture the this
value.
I think it actually depends on what are you going to do inside your doSomething
function. If you are going to access MyObject
properties using this keyword then you have to use that. But I think that the following code fragment will also work if you are not doing any special things using object(MyObject)
properties.
function doSomething(){
.........
}
$("#foobar").ready('click', function(){
});