admin管理员组文章数量:1024080
how do I restart a Javascript function (node.js environment) from inside that has been declared like this:
exports.myfunction = function(parameter){
//myfunction(); does not work
}
how do I restart a Javascript function (node.js environment) from inside that has been declared like this:
exports.myfunction = function(parameter){
//myfunction(); does not work
}
Share
Improve this question
edited Aug 31, 2014 at 15:49
user663031
asked Aug 31, 2014 at 15:08
Igor P.Igor P.
1,4773 gold badges22 silver badges37 bronze badges
2
- 3 Can you clarify what you mean by "restart?" I will assume you mean to recursively call it. Have you tried this.myfunction() or even exports.myfunction() ? – Antiga Commented Aug 31, 2014 at 15:11
- Yes, I was talking about a recursive function call. – Igor P. Commented Sep 1, 2014 at 19:32
2 Answers
Reset to default 6Name it:
exports.myfunction = function myfunction(parameter) {
// ^^^^^^^^^^
myfunction(); // does now work (but leads to a stack overflow obviously)
}
exports.myfunction = function(parameter){
exports.myfunction(); // this works
}
how do I restart a Javascript function (node.js environment) from inside that has been declared like this:
exports.myfunction = function(parameter){
//myfunction(); does not work
}
how do I restart a Javascript function (node.js environment) from inside that has been declared like this:
exports.myfunction = function(parameter){
//myfunction(); does not work
}
Share
Improve this question
edited Aug 31, 2014 at 15:49
user663031
asked Aug 31, 2014 at 15:08
Igor P.Igor P.
1,4773 gold badges22 silver badges37 bronze badges
2
- 3 Can you clarify what you mean by "restart?" I will assume you mean to recursively call it. Have you tried this.myfunction() or even exports.myfunction() ? – Antiga Commented Aug 31, 2014 at 15:11
- Yes, I was talking about a recursive function call. – Igor P. Commented Sep 1, 2014 at 19:32
2 Answers
Reset to default 6Name it:
exports.myfunction = function myfunction(parameter) {
// ^^^^^^^^^^
myfunction(); // does now work (but leads to a stack overflow obviously)
}
exports.myfunction = function(parameter){
exports.myfunction(); // this works
}
本文标签: javascriptHow can I call an exported function from itselfStack Overflow
版权声明:本文标题:javascript - How can I call an exported function from itself? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745526625a2154553.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论