Node.js中的函数构造函数是什么?

在浏览器(至lesschrome)函数是Function实例

 setTimeout instanceof Function // true 

但是在节点中,它们不是

 setTimeout instanceof Function // false 

那么setTimeout的构造Function什么Function呢?

看起来构造函数是Function ,但是来自另一个领域的Function

如果你运行这个代码

 console.log(Object.getOwnPropertyNames(setTimeout.constructor.prototype)); 

你会得到一个典型的Function.prototype方法,比如callapplybind

所以我猜这有点类似于当你从iframe借用setTimeout时候在web浏览器中发生的事情:

 var iframe = document.createElement('iframe'); document.body.appendChild(iframe); var win = iframe.contentWindow; console.log(win.setTimeout instanceof Function); // false console.log(win.setTimeout instanceof win.Function); // true