node.js是否与浏览器中的window对象等效 [英] Does node.js have equivalent to window object in browser
本文介绍了node.js是否与浏览器中的window对象等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的意思是node.js的对象是全局函数方法。在浏览器中这样:
What I mean is does node.js have object that are global function methods of. Like this in browser:
function myGlobalFunction() {
console.log(this === window);
}
myGlobalFunction();
=> true
推荐答案
节点中最接近的等价物是全球
。我不确定它是否以所有相同的方式进行翻译,但是如果你打开一个REPL并输入这= = global
,它将返回true。
The closest equivalent in node is global
. I'm not sure if it translates in all of the same ways, but if you open a REPL and type in this === global
, it will return true.
这里是关于全局对象的讨论,虽然有些信息可能因为它已经过时而被弃用: node.js中的'全局'对象
Here's a discussion on the global object, though some it the information may be deprecated as it's pretty old: 'Global' object in node.js
这篇关于node.js是否与浏览器中的window对象等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文