【发布时间】:2014-06-06 16:28:53
【问题描述】:
如果我想从已经存在同名变量的范围内访问全局上下文中定义的变量:
var variable = 'value';
function someScope(variable){
variable = 'not this';
var global = Function('return this')();
console.log('this > ', global.variable);
}
是否仍有可能以某种方式访问全局变量?
global 对象和 getting the Global object 都不起作用。 (global.variable 返回未定义)
【问题讨论】:
-
@feeela 和其他反对者,我稍微改变了这个问题。请看一看。
标签: node.js global-variables scope