[英]Global Function Context
我创建了一个名为run ()
的函数,但在module.export
的上下文中找不到它。 存储此函数的上下文是什么?
function run(){
function run2(){
console.log(this === global)
console.log(this === module)
}
run2()
}
console.log(module.exports)
上下文是global
。 您必须导出它才能在module.export
对象中找到它。
尝试这个
module.exports.run = function() {
function run2() {
console.log(this === global)
console.log(this === module)
}
run2()
}
console.log(module.exports)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.