Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript console.debug()无法正常工作_Javascript_Google Chrome - Fatal编程技术网

Javascript console.debug()无法正常工作

Javascript console.debug()无法正常工作,javascript,google-chrome,Javascript,Google Chrome,我注意到console.debug()并不总是像预期的那样工作(至少在google chrome中是这样)。例如,在下面的代码中,console.debug(dirs)工作正常,直到alert(dirs)函数工作为止。但是当我告诉chrome停止页面上的警报窗口时,console.debug(dirs)开始显示一个空数组([])。 但是,如果我在for循环中打印数组,我会发现它实际上不是空的 var dirs = [ 0, 1, 2, 3 ]; console.debug ( dirs ); a

我注意到console.debug()并不总是像预期的那样工作(至少在google chrome中是这样)。例如,在下面的代码中,console.debug(dirs)工作正常,直到alert(dirs)函数工作为止。但是当我告诉chrome停止页面上的警报窗口时,console.debug(dirs)开始显示一个空数组([])。 但是,如果我在for循环中打印数组,我会发现它实际上不是空的

var dirs = [ 0, 1, 2, 3 ];
console.debug ( dirs );
alert ( dirs );
代码是通过

setInterval ( "function_with_the_code()", 20 )

Chrome/SafariWebInspector和Opera Dragonfly输出实时对象

那么,代码呢

for(var a=[],i=0;i<5;i++){a.push(i),console.log(a);}

将输出

Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
0
0,1
0,1,2
0,1,2,3
0,1,2,3,4
但是,

for(var a=[],i=0;i<5;i++){a.push(i),console.log(a++);}

将输出

Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
0
0,1
0,1,2
0,1,2,3
0,1,2,3,4

不记得IE F12、Firebug或本机Firefox控制台。

Chrome/Safari WebInspector和Opera Dragonfly输出实时对象

那么,代码呢

for(var a=[],i=0;i<5;i++){a.push(i),console.log(a);}

将输出

Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
0
0,1
0,1,2
0,1,2,3
0,1,2,3,4
但是,

for(var a=[],i=0;i<5;i++){a.push(i),console.log(a++);}

将输出

Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
Array [0, 1, 2, 3, 4]
0
0,1
0,1,2
0,1,2,3
0,1,2,3,4

我不记得IE F12、Firebug或本机Firefox控制台了。

很抱歉,我仍然不明白为什么静态数组不能正确显示,除非我放了警报()很抱歉,但我仍然不明白为什么静态数组不能正确显示,除非我放了警报()