首页 > 编程知识 正文

for的嵌套语句是如何执行的,while循环嵌套两个while

时间:2023-05-05 13:45:42 阅读:12100 作者:643

jslintkeepscomplainingaboutthingslikethis

var myarray=[ 1,2,3 ];

虚拟现实(for ) )。

{

//BLAH

}

sayingthatishouldwrapitinanifstatement.irealizeyouneedtowrapitifyouareloopingoveranobject ' sproperties,butherewhatshouldiouldies

additionallywhenidosomethinglike

for(varI=0; i 10; I )

{

//foo

}

for(varI=0; i 20; I )

{

//bar

}

itcomplainsthatihasalreadybeendefined.howdoipreventthisotherthanusingdifferentvariablenames?

jlintwhingesaboutalotthat ' snotreallyharmful.inthiscaseit ' srighttocomplainaboutfor.in,becausethat'sthewrongconstrong

thisisbecauseyouwillgetnotonlythenumerickeys,utalsoanyotherarbitrarypropertiesthavebeenaddedtothearrayoritsarray.protottay

whilstyoucandefeatthatcasewithhasownpropertytocheckit ' snotaprototypemember,it ' suglierthanjustdoingittheproperwaywithfor

Also,with for . inyouwon ' tnecessarilygettheitemsinnumericalorderasyoumightexpect。

itcomplainsthatihasalreadybeendefined.howdoipreventthisotherthanusingdifferentvariablenames?

yah,you can ignore that one。

itwantsyoutoremovethevarfromthesecondfor (I…, becausedeclaringavariabletwiceinthesamescopedoesn ' tdo anything.howeveriwouldrecommendleavingthevartherebecauseitdoesn ' tdo andifyoumovethelooptoanotherblockyoudon ' twantittobesuddenlyscribblingonglobals。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。