[英]Firebug is printing one addtional numbers when executing code in its command line
I was executing JavaScript within Firebug's console. 我在Firebug的控制台中执行JavaScript。 While running the below loop I have noticed it's printing one additional number: 在运行以下循环时,我注意到它正在打印一个额外的数字:
var i = 0;
while(i<10) {
console.log(i);
i++;
}
It's providing the following output: 它提供以下输出:
var i = 0; while(i<10) { console.log(i); i++; }
0
1
2
3
4
5
6
7
8
9
9
Is this a bug or something else? 这是错误还是其他?
The last 9
, which is causing disturbance, is the return value of console.log()
. 导致干扰的最后9
值是console.log()
的返回值。 Try alert(i)
instead of console.log(i)
. 尝试使用alert(i)
而不是console.log(i)
。
The Console panel outputs the return values of scripts executed through the Command Line or the Command Editor . “ 控制台”面板输出通过命令行或命令编辑器执行的脚本的返回值。 Unfortunately Firebug does not visually differentiate the return value from the output created through console.log()
. 不幸的是,Firebug不会在视觉上将返回值与通过console.log()
创建的输出区分开。 So the second 9
at the end of the output is the return value. 因此,输出末尾的第二个9
是返回值。
Within the Firefox built-in DevTools this is more obvious: 在Firefox 内置的DevTools中,这一点更加明显:
Note that the output of the return value cannot be suppressed. 注意,返回值的输出不能被抑制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.