# 17. Learn backbone.js tutorial from scratch for beginners(Part 20) Underscore js Methods in backbone

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS6SbR_SvPuWlUYyU62%2F-MS6TicC1i9dh7owyM7k%2FScreenshot_2.jpg?alt=media\&token=2150f85f-f458-4e9b-84ba-f5cadb32dfb2)

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS6wIZrMPS6PFf0QxQq%2F-MS6zO629r7QQ8wWygbq%2FScreenshot_1.jpg?alt=media\&token=19bf44a4-5a43-47b9-89ef-51f08b1d15e2)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
  	defaults: {
  		name: 'Lionel',
  		team: "Viet Nam",
  		no: 10
  	}
  });
  
  var model1 = new FirstModel({
  	name: 'Lionel 1',
  	team: "VietNam",
  	no: 16
  });
  var model2 = new FirstModel({
  	name: 'Lionel 2',
  	team: "India",
  	no: 17
  });
  var model3 = new FirstModel({
  	name: 'Lionel 3',
  	team: "Korea",
  	no: 18
  });
  var MyCollection =  Backbone.Collection.extend({
  	model: FirstModel
  });
  var MycollectionObj = new MyCollection([model1, model2, model3]);
  var ModelView = Backbone.View.extend({
  	collection: MycollectionObj,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		_.each(this.collection.toJSON(), function(model) {
  			console.log(model.name + " , " + model.team);
  		});
  	}
  });
  vmodel = new ModelView();
});
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS6zaAFEG7GuAHzf7Io%2F-MS7-CvpIyRrkm-ttuHc%2FScreenshot_2.jpg?alt=media\&token=b765da21-4a25-4bcd-ad0f-d84daa85a939)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
  	defaults: {
  		name: 'Lionel',
  		team: "Viet Nam",
  		no: 10
  	}
  });
  
  var model1 = new FirstModel({
  	name: 'Lionel 1',
  	team: "VietNam",
  	no: 16
  });
  var model2 = new FirstModel({
  	name: 'Lionel 2',
  	team: "India",
  	no: 18
  });
  var model3 = new FirstModel({
  	name: 'Lionel 3',
  	team: "Korea",
  	no: 18
  });
  var MyCollection =  Backbone.Collection.extend({
  	model: FirstModel
  });
  var MycollectionObj = new MyCollection([model1, model2, model3]);
  var ModelView = Backbone.View.extend({
  	collection: MycollectionObj,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		var data = _.where(this.collection.toJSON(), {no: 18});
  		console.log(data);
  	}
  });
  vmodel = new ModelView();
});
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS7-j9yRzOkJ3RyJDze%2F-MS700zjN0_3vE_5E5qA%2FScreenshot_3.jpg?alt=media\&token=d6d537f3-07a4-402f-bdf9-ba07474c462a)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
  	defaults: {
  		name: 'Lionel',
  		team: "Viet Nam",
  		no: 10
  	}
  });
  
  var model1 = new FirstModel({
  	name: 'Lionel 1',
  	team: "VietNam",
  	no: 16
  });
  var model2 = new FirstModel({
  	name: 'Lionel 2',
  	team: "India",
  	no: 18
  });
  var model3 = new FirstModel({
  	name: 'Lionel 3',
  	team: "Korea",
  	no: 18
  });
  var MyCollection =  Backbone.Collection.extend({
  	model: FirstModel
  });
  var MycollectionObj = new MyCollection([model1, model2, model3]);
  var ModelView = Backbone.View.extend({
  	collection: MycollectionObj,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		var data = _.findWhere(this.collection.toJSON(), {no: 18}); // retrun result first
  		console.log(data);
  	}
  });
  vmodel = new ModelView();
});
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1E4Gk2ppVKb4olmnun%2F-MS72HHisLMiR-Bys2Dl%2F-MS72XDFQu4dGSZR-AUq%2FScreenshot_6.jpg?alt=media\&token=c4838691-be00-4eec-913a-9924a3cd1c49)

C:\Users\Administrator\Desktop\gulp\app.js

```
jQuery(document).ready(function($) {
  var FirstModel = Backbone.Model.extend({
  	defaults: {
  		name: 'Lionel',
  		team: "Viet Nam",
  		no: 10
  	}
  });
  
  var model1 = new FirstModel({
  	name: 'Lionel 1',
  	team: "VietNam",
  	no: 16
  });
  var model2 = new FirstModel({
  	name: 'Lionel 2',
  	team: "India",
  	no: 18
  });
  var model3 = new FirstModel({
  	name: 'Lionel 3',
  	team: "Korea",
  	no: 18
  });
  var MyCollection =  Backbone.Collection.extend({
  	model: FirstModel
  });
  var MycollectionObj = new MyCollection([model1, model2, model3]);
  var ModelView = Backbone.View.extend({
  	collection: MycollectionObj,
  	initialize: function() {
  		this.render();
  	},
  	render: function() {	
  		var data = _.pluck(this.collection.toJSON(), "name");
  		console.log(data); // return result first
  	}
  });
  vmodel = new ModelView();
});
```
