Firebug 在其命令行中执行代码时正在打印一个额外的数字

Firebug is printing one addtional numbers when executing code in its command line

我在 Firebug 的控制台中执行 JavaScript。虽然 运行 下面的循环我注意到它打印了一个额外的数字:

var i = 0; 

while(i<10) {
  console.log(i);
  i++;
}

它提供以下输出:

var i = 0;   while(i<10) {   console.log(i);   i++; } 
0
1
2
3
4
5
6
7
8
9
9

这是错误还是其他原因?

引起干扰的最后一个9console.log()的return值。尝试 alert(i) 而不是 console.log(i).

Console panel outputs the return values of scripts executed through the Command Line or the Command Editor。不幸的是,Firebug 无法从视觉上区分 return 值与通过 console.log() 创建的输出。所以输出末尾的第二个 9 是 return 值。
在 Firefox built-in DevTools 中更明显:

请注意,无法抑制 return 值的输出。