I am trying to understand what is the difference between these two jQuery snippets as they will have the same result.
1
var method = {
myFunctionA: function() {
// do something
},
myFunctionB: function() {
// do something
},
}
$(selector1).click(function() { method.myFunctionA(this) });
$(selector2).click(function() { method.myFunctionB(this) });
2
function myFunctionA(){
// do something
}
function myFunctionB(){
// do something
}
$(selector1).click(myFunctionA);
$(selector2).click(myFunctionB);
$, this is really a Javascript question.