2013-04-02 114 views
1

我试图让该函数的功能与参数子功能的Javascript调用内部函数功能

function firstF(){ 
    this.childF1 = function($argument){ 
    // do something + $argument 
    } 
    this.childF2 = function($argument2){ 
    // do something + $argument2 
    } 
} 

//Declare a new firstF 
var firstFunction = new firstF(); 
firstFunction.childF1 

我如何在这里宣布$参数里面?

+0

'firstF.childF1(“arg”);' – deadlock

+3

我强烈建议您阅读https://developer.mozilla.org/en-US/docs/JavaScript/Introduction_to_Object-Oriented_JavaScript – plalx

回答

2

你不喜欢这样:

var firstFunction = new firstF(); 
firstFunction.childF1(arghere) 

childF1是你firstF对象的属性,该属性是一个函数。所以,你把它称为parens的函数,并将参数传递给parens。您必须在firstF类型的已创建对象上调用它,而不是在firstF函数本身上调用它。

相关问题