Javascript:为什么 .toString() 不显示某些函数的代码?
Javascript: Why doesn't .toString() reveal code for some functions?
我刚刚安装了 sleep
Node.js 模块并已在我的代码中实现。当我尝试以下代码 console.log(sleep.usleep.toString());
时,结果显示 [native code]
而不是 usleep()
中的实际代码,但是当我对我的函数尝试相同的操作时,它包括 [native code]
中的所有代码=24=] .toString()
的值:
function a() {
//code
}
console.log(a.toString());
为什么.toString()
不泄露sleep.usleep()
里面的代码?
[Native code]
表示它是在浏览器的 javascript 引擎中以 native
代码而非 javascript
.
实现的功能
我刚刚安装了 sleep
Node.js 模块并已在我的代码中实现。当我尝试以下代码 console.log(sleep.usleep.toString());
时,结果显示 [native code]
而不是 usleep()
中的实际代码,但是当我对我的函数尝试相同的操作时,它包括 [native code]
中的所有代码=24=] .toString()
的值:
function a() {
//code
}
console.log(a.toString());
为什么.toString()
不泄露sleep.usleep()
里面的代码?
[Native code]
表示它是在浏览器的 javascript 引擎中以 native
代码而非 javascript
.