【发布时间】:2016-01-06 06:45:37
【问题描述】:
var foo = 0, bar = 0
process.nextTick(function() {
debugger
})
使用node debug进入节点REPL,尝试打印一些变量,发现foo和bar也无法访问:ReferenceError: foo is not defined
var foo = 0, bar = 0
process.nextTick(function() {
console.log(foo)
})
process.nextTick(function() {
debugger
})
但不知何故,我从另一个异步回调函数“访问”foo,它变得可见,打印bar 仍然引发ReferenceError。
是关于 V8 JIT 还是 Node 实现细节?
【问题讨论】: