在下面的代码中,在断点处暂停时,Chrome开发工具会告诉我"foo"是或否未定义,这取决于console.log行是否被注释掉。
一旦到达断点,如果您在控制台中键入"foo",或者将其添加为观察变量,如果控制台语句已被注释,则会显示foo未定义,但是如果控制台语句未被注释,则会正确显示foo的值(1)。为什么会这样?
一旦到达断点,如果您在控制台中键入"foo",或者将其添加为观察变量,如果控制台语句已被注释,则会显示foo未定义,但是如果控制台语句未被注释,则会正确显示foo的值(1)。为什么会这样?
function func1(){
let foo = 1;
var func2 = function (){
function func3 (){
let foo2 = 4;
// put breakpoint here
let foo3 = 5;
// console.log(foo); //says foo is undefined when this line commented
}
func3();
}
func2();
}
func1();