JSFiddle - React, Tailwind, and code Playground

by deepak sisodiya

HTML

<script src="https://rawgit.com/jashkenas/underscore/1.5.2/underscore-min.js"></script>
<script src="https://rawgit.com/jashkenas/backbone/1.0.0/backbone-min.js"></script>
Backbone collections are simply an ordered set of models. Such that it can be used in situations such as: Model: Student, Collection: ClassStudents Model: Animal, Collection: Zoo
<hr>Typically your collection will only use one type of model but models themselves are not limited to a type of collection: Model: Student, Collection: Gym Class Model: Student, Collection: Art Class Model: Student, Collection: English Class

JavaScript

// backbone.js 7 collections

var alert = function (str) {
    var st = document.createTextNode(str);
    var p = document.createElement('p');
    p.appendChild(st);
    document.querySelector('body').appendChild(p);
}

var Song = Backbone.Model.extend({
    defaults: {
        name: "Not specified",
        artist: "Not specified"
    },
    initialize: function () {
        alert("Music is the answer");
    }
});

var Album = Backbone.Collection.extend({
    model: Song
});

var song1 = new Song({name: "How Bizarre",artist: "OMC"});
var song2 = new Song({name: "Sexual Healing",artist: "Marvin Gaye"});
var song3 = new Song({name: "Talk It Over In Bed",artist: "OMC"});

var myAlbum = new Album([song1, song2, song3]);
alert(JSON.stringify(myAlbum.models))