【发布时间】:2017-02-18 03:17:00
【问题描述】:
在节点中,为什么我在这个例子中没有定义?
由于我没有使用严格模式,这应该可以从函数内部访问并且等于 Global 对象。
this.foo = "bar";
function fun () {
console.log(this.foo);
}
fun(); // undefined
【问题讨论】:
-
@Mohammad,在 Node 上是这样
-
使用
global获取全局对象。
标签: javascript node.js