Skip to content

Instantly share code, notes, and snippets.

@nakajmg
Created February 16, 2015 11:47
Show Gist options
  • Save nakajmg/142edc78ba2b3a788223 to your computer and use it in GitHub Desktop.
Save nakajmg/142edc78ba2b3a788223 to your computer and use it in GitHub Desktop.
function Model(name) {
this.name = name;
}
function Collection(models) {
this.models = models;
}
Collection.prototype.showName = function() {
this.models.forEach(function(model) {
console.log(model.name);
});
}
var models = []
models.push(new Model("hoge1"));
models.push(new Model("hoge2"));
models.push(new Model("hoge3"));
var collection = new Collection(models);
collection.showName();
// hoge1
// hoge2
// hoge3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment