var TestView = Backbone.View.extend({
options: {
"theList": []
},
initialize: function() {
console.log(this.options.theList.length);
this.options.theList.push("xxx");
}
});
// other place:
var view1 = new TestView();
// the console result will be 0
var view2 = new TestView();
// the console result will be 1 !!!
var view3 = new TestView();
// the console result will be 2 !!!!!!
...
为什么?我认为每次我都会控制台new
0 TestView
!