scope - Node.js variables scoping in debugger -


var foo = 0, bar = 0 process.nexttick(function() {   debugger }) 

entering node repl using node debug, , trying print variables, found foo , bar can not accessed either: referenceerror: foo not defined

var foo = 0, bar = 0 process.nexttick(function() {   console.log(foo) })  process.nexttick(function() {   debugger }) 

but somehow 'access' foo async callback function, became visible, print bar still raises referenceerror.

is v8 jit or node implementing details?

there seems nothing wrong code, not sure how used debugger try node-inspector better debugging experience.

you can use console.log current scope value. same example in browser environment.

var foo = 0, bar = 0  window.settimeout(function() {      console.log(foo, bar);  }, 0);


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -