node.js中的“全局"对象 [英] 'Global' object in node.js
问题描述
我正在使用0.3.1-pre Node.js
I am using 0.3.1-pre Node.js
这样做:
typeof global.parseInt
结果
'undefined'
但是,在键入"global"后在控制台中按[Tab]时.给出函数列表,包括parseInt.
However when pressing [Tab] in the console after typing 'global.' gives a list of functions, including parseInt.
那么parseInt是否是 global 命名空间的成员?
So is parseInt a member of the global namespace or not?
推荐答案
显然,global
对象不是全局对象,因为window
在浏览器中. (根据#nodejs @ freenode中的micheil)实际上仅在内部使用.关于全局关闭和其他方面的内容.
Apparently, the global
object isn't the global object as window
is in the browser. It's (according to micheil in #nodejs @ freenode) really only used internally. Something about global closures and whatnot.
parseInt
和setTimeout
以及所有这些伙伴都是全局变量.不属于任何可见的全局对象.
parseInt
and setTimeout
and all those buddies are globals on their own. Not part of any visible global object.
这篇关于node.js中的“全局"对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!