How to get model name from a collection with backbone.js

http://stackoverflow.com/questions/12427579/how-to-get-model-name-from-a-collection-with-backbone-js/12427765#12427579

by fguillen

HTML

<script src="http://documentcloud.github.com/underscore/underscore.js"></script>
<script src="http://documentcloud.github.com/backbone/backbone.js"></script>

JavaScript

var MyModel = Backbone.Model.extend({
    name: "MyModel"
});

var MyCollection = Backbone.Collection.extend({
    model: MyModel
});

var myCollection = new MyCollection();

console.log( "reference", myCollection.model );
console.log( "reference.name", myCollection.model.prototype.name );