简体   繁体   中英

how to display local scoped variable in chrome's javascript console

I'm using chrome's javascript console to debug some javascript. And often I'm using the interactive command line to display some variables. When I'm in a function (halted by a breakpoint), and type in the name of a parameter (in my case "result") in the command line it displays the value of the global scoped result instead of the local scoped result. Is there a way to tell chrome's command line to evaluate the local scoped or inner most scoped variable in stead of the global scoped variable?

cheers.

Looks like you make some mistake. I try next example:

var b=1;
function foo() {
    var b=2;
    debugger
}
foo();

"b" is equal 2, even if you will declare one function inside another one, if you will declare "b" with "var" - you will see you want.

Any additional information? maybe you have an example of code?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM