在javascript中调用另一个函数内的函数

时间:2013-02-14 09:34:10

标签: javascript

将Person功能定义如下,

function Person() {
    this.GetContactDetail = function() {

        // Can I make a call to GetFullDetail  function over here is it possible , 
        // I tried but it doesnt calls the GetFullDetail  function
        this.GetFullDetail; 
    };

    this.GetFullDetail = function() {

    };
};

var objPer = new Person();
objPer.GetContactDetail();

以上代码只是参考的片段。

3 个答案:

答案 0 :(得分:1)

为了在javascript中调用函数,您应该在其名称后面使用()。只是引用它,就不会调用它。

所以你应该这样做:

this.GetFullDetail(); 

答案 1 :(得分:0)

调用函数

  this.GetFullDetail();

this.GetFullDetail;显示Person variable

答案 2 :(得分:-1)

GetContactDetails中的

this不是指Person,而是指GetContactDetails上下文。您应该在{。}}之外保存对{。}}的引用。

this