How to call a method inside a javascript object

后端 未结 5 575
北荒
北荒 2021-02-08 17:30

I\'m just learning about how to best organize my javascript code, and I had a question regarding this small piece of code I wrote:

var reportsControllerIndex = {         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 18:16

    plotMapPoints: function(data) {
        //plots points
    }.bind(this)
    

    when defining your function you can just add .bind(this) to set the correct context for that function.

提交回复
热议问题