Created
August 23, 2011 08:27
-
-
Save lennym/1164645 to your computer and use it in GitHub Desktop.
Object passing by reference in Backbone.Model default values.
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
var TestModel = Backbone.Model.extend({ | |
defaults: { | |
primitiveProp: 'foo', | |
objectProp: { | |
prop1: 'val', | |
prop2: null | |
} | |
} | |
}); | |
var model = new TestModel(); | |
var objProp = model.get('objectProp'); | |
objProp['prop2'] = 'bar'; | |
console.log(TestModel.prototype.defaults.objectProp.prop2); | |
// => 'bar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment