如何从自身调用导出的函数?

时间:2014-08-31 15:08:56

标签: javascript

如何从已声明的内部重新启动Javascript函数(node.js环境):

exports.myfunction = function(parameter){
   //myfunction(); does not work
}

2 个答案:

答案 0 :(得分:5)

Name it

exports.myfunction = function myfunction(parameter) {
//                            ^^^^^^^^^^
    myfunction(); // does now work (but leads to a stack overflow obviously)
}

答案 1 :(得分:2)

exports.myfunction = function(parameter){
   exports.myfunction(); // this works
}