为什么typeof null的值在循环内发生变化? [英] Why does the value of typeof null change inside a loop?
本文介绍了为什么typeof null的值在循环内发生变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Chrome控制台中执行此代码段:
Executing this snippet in the Chrome console:
function foo() {
return typeof null === 'undefined';
}
for(var i = 0; i < 1000; i++) console.log(foo());
应打印1000次 false
,但在某些机器上会打印<$ c对于多次迭代,$ c> false ,其余为 true
。
should print 1000 times false
, but on some machines will print false
for a number of iterations, then true
for the rest.
为什么会发生这种情况?这只是一个错误吗?
Why is this happening? Is it just a bug?
推荐答案
为此开放了一个铬虫:
< a href =https://bugs.chromium.org/p/chromium/issues/detail?id=604033>问题604033 - JIT编译器不保留方法行为
所以是的,这只是一个错误!
So yes It's just a bug!
这篇关于为什么typeof null的值在循环内发生变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文