本文介绍了在'for'循环中使用相等 - 为什么不呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! ''for''循环需要3个参数(initialize; test; increment)。 ''测试'' 必须等同于真或假 这不起作用...... x = 5; for(y = 1;(y == 5); y + = 1){ alert(x * y); } ...也不... x = 5; for(y = 1;(y === 5) ; y + = 1){ alert(x * y); } ....但是这样做.. x = 5; for(y = 1;(y alert(x * y); } 为什么前两个失败?如果我是值5然后i == 5是真的,那么 i === 5. 任何人都可以解释我在这里缺少的东西? 问候 解决方案 你错过了文档: http://tinyurl.com/jbie - Hywel我不吃乳蛋饼 http://kibo.org.uk/ http://kibo.org.uk/mfaq.php 马克 问候, Erwin Moller 你设置x = 5和y = 1并且似乎对y!= 5感到惊讶。 不知道你,这很难猜测这是否是疏忽 或者你是否真的遗失了什么。 A ''for'' loop takes 3 arguments (initialize; test; increment). The ''test''must equate as true or falseThis doesn''t work...x = 5;for (y=1; (y==5); y+=1) {alert(x * y);}...nor does...x = 5;for (y=1; (y===5); y+=1) {alert(x * y);}....but this does..x = 5;for (y=1; (y<6); y+=1) {alert(x * y);}Why do the first two fail? If i is value 5 then i==5 is true, as isi===5.Can anyone explain what I''m missing here?Regards 解决方案You''re missing the documentation: http://tinyurl.com/jbie--Hywel I do not eat quiche http://kibo.org.uk/ http://kibo.org.uk/mfaq.phpRegards,Erwin MollerYou''re setting x=5 and y=1 and seem to be surprised that y!=5.Without knowing you, it''s hard to guess whether this is oversightor if you really are missing something. 这篇关于在'for'循环中使用相等 - 为什么不呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-26 17:14
查看更多