获取node.js中当前定义的函数列表

时间:2012-09-11 00:24:42

标签: node.js

是否有任何函数可用于列出node.js中所有当前定义的函数?我想创建一个这样的函数:

function getAllDefinedFunctions(){
    //return all the functions that are currently defined
}

1 个答案:

答案 0 :(得分:3)

您可以使用for / in循环遍历this(全局对象)中的所有属性,并检查typeof this[name]是否为'function'