Created
February 16, 2015 11:47
-
-
Save nakajmg/142edc78ba2b3a788223 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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