I would like to know what is difference in writing in below 2 ways :
Approach 1:
var onCallback = function(result) {
alert('way1');
};
function1(onCallback);
Approach 2:
function2(function(result) {
alert('way2');
});
I would like to know what is difference in writing in below 2 ways :
Approach 1:
var onCallback = function(result) {
alert('way1');
};
function1(onCallback);
Approach 2:
function2(function(result) {
alert('way2');
});
Approach 1 could be reused. (which might do some problems, because the code can be altered, but shouldn't)
Approach 2 has no refference
that's the only difference