If I have a list of functions that are serving as event subscriptions, is there an advantage to running through them and calling them with .call() (B below), or more directly (A)? The code is below. The only difference I can see is that with .call you can control what this is set to. Is there any other difference besides that?
$(function() {
eventRaiser.subscribe(function() { alert("Hello"); });
eventRaiser.subscribe(function(dt) { alert(dt.toString()); });
eventRaiser.DoIt();
});
var eventRaiser = new (function() {
var events = [];
this.subscribe = function(func) {
events.push(func);
};
this.DoIt = function() {
var now = new Date();
alert("Doing Something Useful");
for (var i = 0; i < events.length; i++) {
events[i](now); //A
events[i].call(this, now); //B
}
};
})();