Skip to content

Instantly share code, notes, and snippets.

@leobalter
Created October 18, 2011 23:49
Show Gist options
  • Save leobalter/1297100 to your computer and use it in GitHub Desktop.
Save leobalter/1297100 to your computer and use it in GitHub Desktop.
var Song = Backbone.Model.extend({
defaults: {
name: "Not specified",
artist: "Not specified"
},
initialize: function() {
console.log("Music is the answer");
}
}), Album = Backbone.Collection.extend({
model: Song
}), song1 = new Song({
name: "How Bizarre",
artist: "OMC"
}), song2 = new Song({
name: "Sexual Healing",
artist: "Marvin Gaye"
}), song3 = new Song({
name: "Talk It Over In Bed",
artist: "OMC"
}), myAlbum = new Album([ song1, song2, song3 ]);
console.log(myAlbum.models);
var a = "</script>"; // => var a="<\/script>"
function f(a, b, c, d, e) {
var q;
var w;
w = 10;
q = 20;
for (var i = 1; i < 10; ++i) {
var boo = foo(a);
}
for (var i = 0; i < 1; ++i) {
var boo = bar(c);
}
function foo(){ /*...*/ }
function bar(){ /*...*/ }
function baz(){ /*...*/ }
}
function f(a, b, c) {
var f, g, h, i;
function j() {}
function k() {}
g = 10, f = 20;
for (h = 1; h < 10; ++h) i = j(a);
for (h = 0; h < 1; ++h) i = k(c);
}
var Song = Backbone.Model.extend({
defaults: {
name: "Not specified",
artist: "Not specified"
},
initialize: function() {
console.log("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]);
console.log(myAlbum.models); // [song1, song2, song3]
var Song=Backbone.Model.extend({defaults:{name:"Not specified",artist:"Not specified"},initialize:function(){console.log("Music is the answer")}}),Album=Backbone.Collection.extend({model:Song}),song1=new Song({name:"How Bizarre",artist:"OMC"}),song2=new Song({name:"Sexual Healing",artist:"Marvin Gaye"}),song3=new Song({name:"Talk It Over In Bed",artist:"OMC"}),myAlbum=new Album([song1,song2,song3]);console.log(myAlbum.models)
obj.toString() // => obj+""
new Array(1, 2, 3, 4) // => [1,2,3,4]
Array(a, b, c) // => [a,b,c]
new Array(5) // => Array(5)
new Array(a) // => Array(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment