I've come across some code that has this sort of pattern in numerous places:
this.someFunction.call(this, param);
but it seems to me just a more verbose way of typing
this.someFunction(param)
The pattern sometimes appears inside a function which is provided as a callback. It happens to use Backbone, in case that's relevant. Something like this:
Backbone.View.extend({
// other stuff ...
someFunction: function(param) {
// ...
},
anotherFunction: function() {
this.collection.on("some_event", function() {
this.someFunction.call(this, param);
});
}
});
Does the pattern actually have an effect that isn't the equivalent of this.someFunction(param)
or was someone just nervous about the closure not capturing the correct this
?
Thanks for any insights!