How to call a method inside a javascript object

后端 未结 5 1462
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-08 17:23

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:04

    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.

提交回复
热议问题