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

时间:2021-06-19 07:26:32

how do I restart a Javascript function (node.js environment) from inside that has been declared like this:

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

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

2 个解决方案

#1


4  

Name it:

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

#2


1  

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

#1


4  

Name it:

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

#2


1  

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