请解惑关于charAt("J")

 for(var i=0;i<str.length;i++){

        if(str[i].charAt("J")==="J" && str.substr(i,10)){ //通charAt属性查找J的位置

           //截取JavaScript的位置

                document.write("JavaScript第"+sum+"次出现是在"+i+"的位置"+"<br />");

                 //每出现一次增加1

 if(str[i].charAt("J") ===“J"这句话 看不懂。charAt应该是跟个索引的 为什么这样不会报错呢?if(str[i].charAt("J")==="J" 

慕圣2157743
浏览 859回答 2
2回答

慕设计2395807

PIUXMJFHRIQMUKZPSUKTKARNBRGWZCZCYSILTILAQZXTNKMVLHKGVMACRTJSBEBQBEKYNJGISHWGQWEAWZVXHXTXAJFBPMPRADNCYNQXNQFBEVIKTADTWFVRAPYHJZVXSVFBBXTPSIQTPFVQHCZIEGHXNQFBWZCKTJSVEIRAWMBDMCMIFUEAPKNDTWZLNJMIEZVYBREXJWFCIFEYOAIFHXZVSBKHBDZCFUQMVFVCLTWMOEBVZOHKZPRUKGPFIUJFVRAJZCYBUPZBKUWNRNRZIEHQZVRUQAEGCYOWLHDMWXGWRBEAJZPSENDTPFBKNPMCYNKSPFOQTWNDZOLAJZPFBJMMPFBEHJTWYVDGVLNIFVLGIETBLADFBLHWFVENJMCFADSVCZVEHEUXUDFHWMIRGWNVDAPSHDAVFGNCYBRAWMUEZFBWTAJZCLVMCYHRMJZIXTWQSOJFOKGISCFOQAVKAQFBYAJMCRHQGUQGIRZJEGCSVYURHWGILHWSOXRNJMPLAJZIYNCYBQGVFIYATJFVRGDZOLBBXZJSVRYBSOQYORAJYMWZVMPRUQGIEAKOXAJMOKMIKBKEAJFVKNQSVYPRTPYVDSUFIOQZCLOXZWSBJFVJTVLBDGPYUKGILIDMPMOEGPLUDMWYBRNPSVKAQZVLCYNDFHDZIRHUJZPXUPMVRNTIROXNJZOYHRTWZBEBWLVRHENJZGWTIYOLNOXAJRHXUQLBJTJRUQZHKUQLGWLAIYHKRUPMVYUJEAXVEADFUDLHRTUDZCYHKGJMBUXTHQMBROYOMJEBQYUWGPMKNHWTBRBDOEJLBJGWSBYHKIRTWYORUWEHCLOJYBQZCMIYNILHJZCSHRCRADFIEAJZOTVXMBXGJSDF
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript