javascript取得上下文的一个小问题,谢谢了。

现附上一段简单的代码,用的Backbone库

 var NoteCollectionView = Backbone.View.extend({
    tagName: 'ul',

    initialize: function () {
        this.collection.on('add', this.addOne, this);
        this.render();
    },

    render: function () {
        this.collection.each(this.addOne, this);
        return this;
    },

    addOne: function(note) {
        var noteView = new NoteView({model: note});
        this.$el.append(noteView.render().el);
    }
});
var noteCollection = new NoteCollection([note1, note2, note3]);
var noteCollectionView = new NoteCollectionView({collection: noteCollection});

有一个小问题:
initialize: function () {
this.collection.on('add', this.addOne, this);
this.render();
},

render: function () {
this.collection.each(this.addOne, this);
return this;
},

加粗那两个this代表什么意思呢?搞不明白
怎么取得上下文的,困扰了我好久了

一般是指的当前对象。你可以打个断点看一下。

图片说明

哪个对象调用……this就表示是哪个对象