I’m looking at JQuery Tiny Pub/Sub, which looks something like this:
(function($){
var o = $({});
$.subscribe = function() {
o.bind.apply( o, arguments );
};
...
})(jQuery);
What I don’t get is, since the code is calling o.bind, the “this” inside bind is o anyway, therefore there is no reason to use apply.
In other words,
o.bind(arguments)
and
o.bind.apply(o, arguments)
here should be identical shouldn’t they? The why o.bind.apply(o, arguements)?
.applytakes an array of arguments to pass, so they’re not the same thing. Consider this:You may be confusing it with
.call, which would certainly be redundant.