Javascript 回显保存在变量中的函数的代码

Javascript 回显保存在变量中的函数的代码,javascript,node.js,Javascript,Node.js,我正在尝试使用console.log回显node.js中变量中保存的函数代码 xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState == 4){ if (xmlhttp.status == 200){ response=xmlhttp.responseText.split(':') if(1 in response){ va

我正在尝试使用console.log回显node.js中变量中保存的函数代码

xmlhttp.onreadystatechange=function(){
    if (xmlhttp.readyState == 4){
        if (xmlhttp.status == 200){
            response=xmlhttp.responseText.split(':')
            if(1 in response){
                var Exptime = new Date();
                Exptime.setTime(Exptime.getTime() + 86400000);
                document.cookie("pro_cc3=")+response[1]+'; path=/; expires=' + Exptime.toUTCString();
            }
        }
    }       
}
console.log(xmlhttp.onreadystatechange);
如果代码是可访问的,但返回以下内容,则需要将其作为字符串

[Function]

尝试显式调用函数的
toString
方法:

console.log(xmlhttp.onreadystatechange.toString());
确切的格式可能会有所不同,但它几乎总是包含函数体


*一些浏览器,特别是移动浏览器,只显示
[对象函数]
函数(){…}
,但这对您来说应该不是问题。

您是否尝试过xmlhttp.onreadystatchange.toString()?
xmlhttp.onreadystatechange.toString()
,但为什么呢?本文解释了您需要的内容