2014-11-21 158 views
0
var Lines = function(startXCon, endXCon,startYCon, endYCon) 
{ 


    this.drawCurve = function() 
    { 


    } 
    this.changeCurve = function(e) 
    { 
     //how can I call drawCurve from this method 
    } 

} 

我的代碼中的評論解釋了這個問題。這是可能的還是所有的方法是私人的?OOJS呼叫其他方法

回答

0

像這樣:

var Lines = function(startXCon, endXCon,startYCon, endYCon){ 
    var self = this; // store this as a variable to use in nested function 
    this.drawCurve = function(){} 
    this.changeCurve = function(e){ 
    self.drawCurve(); //now call this.drawCurve() 
    } 
}