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?
精彩评论