Skip to content

Instantly share code, notes, and snippets.

@knowtheory
Created May 16, 2012 11:45
Show Gist options
  • Save knowtheory/2709760 to your computer and use it in GitHub Desktop.
Save knowtheory/2709760 to your computer and use it in GitHub Desktop.
Backbone confusion
var test = Backbone.Model.extend({
var1 : [],
initialize : function(obj) {
this.var1.push("1")
console.log(this.var1.length, this.cid)
}
});
var x = (new test);
var y = (new test);
1 "c37"
2 "c38"
//expecting length of 1 each time
var test = Backbone.Model.extend({
var1 : [],
initialize : function(obj) {
this.var1.push("1")
console.log(this.var1.length, this.cid)
}
});
var x = new test()
var y = new test()
1 "c39"
2 "c40"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment