作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在此循环中,alert(i)
警报 12,firebug 显示 10 作为最终结果。
for(var i=0;i<=10;i=i+2){
document.write=i;
}
alert(i);
最佳答案
i
每次循环迭代后都会增加。当它失败时,条件 <= 10
循环中断:
0 => loop gets executed, i incremented with 2
2 => loop gets executed, i incremented with 2
4 => loop gets executed, i incremented with 2
6 => loop gets executed, i incremented with 2
8 => loop gets executed, i incremented with 2
10 => loop gets executed, i incremented with 2
12 => loop breaks => i remains at 12
关于JavaScript,For 循环 : returned 'i' value is different from that is stored,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29939266/
我是一名优秀的程序员,十分优秀!