Backbone example app and javascript apply
backbone.js, javascript
Solution
Variable list of arguments
The key is in the way without is written:
function () {
var args = slice.call(arguments);
args.unshift(this.models);
return _[method].apply(_, args);
}
It's anticipating a variable list of arguments, and one way to do that is to use apply:
...
return this.without.apply(this, ['pass', 'these', 'arguments']);
There's more about apply in the MDN documentation.
Problem
Hi can someone explain why in backbone example app (http://backbonejs.org/examples/todos/index.html) in remaining() function, is called using apply (this.without.apply(this, this.done());) and not this.without(this.done()) ``` // Filter down the list of all todo items that are finished. done: function() { return this.where({done: true}); }, // Filter down the list to only todo items that are still not finished. remaining: function() { return this.without.apply(this, this.done()); }, ``` Thank You ! #Update Debugger output ``` this.without(this.done()) [child, child, child, child] this.without.apply(this, this.done()); [child, child, child] ```