We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Chainable API example I saw this:
var collection = new Backbone.Collection([ { name: 'Tim', age: 5 }, { name: 'Ida', age: 26 }, { name: 'Rob', age: 55 } ]); var filteredNames = collection.chain() // start chain, returns wrapper around collection's models .filter(function(item) { return item.get('age') > 10; }) // returns wrapped array excluding Tim .map(function(item) { return item.get('name'); }) // returns wrapped array containing remaining names .value(); // terminates the chain and returns the resulting array console.log(filteredNames); // logs: ['Ida', 'Rob']
Therefore I tested to just use the collection without the chain() method. It seems that it worked well. I ran this in the console:
var collection = new Backbone.Collection([ { name: 'Tim', age: 5 }, { name: 'Ida', age: 26 }, { name: 'Rob', age: 55 } ]); collection .filter(function(item) { return item.get('age') > 10; }) .map(function(item) { return item.get('name'); }) ;
and it returns ['Ida', 'Rob'].
['Ida', 'Rob']
I'm wondering why? It seems that the chain() method is not necessary? Thanks!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In Chainable API example I saw this:
Therefore I tested to just use the collection without the chain() method. It seems that it worked well. I ran this in the console:
and it returns
['Ida', 'Rob']
.I'm wondering why? It seems that the chain() method is not necessary? Thanks!
The text was updated successfully, but these errors were encountered: