在js中試過類似的代碼,並且正常工作。可能會出現一些問題的代碼行,你沒有張貼或一些問題與您粉可變
<html>
<script>
function fun(){
var powder =[1,2,4,5];
for(var key in powder){
for(var key2 in powder){
if(key == key2){ alert("con");continue; };
}
}
}
</script>
<body onload="fun()"></body>
</html>
下面的代碼將導致違法繼續statement.The continue語句必須出現在循環不在稱爲功能。
<html>
<script>
function funOne(){
for(var i=0;i<10;i++){
fun();
}
}
function fun(){
if(1==1){ //this line is the cause of error
continue;
}
var powder =[1,2,4,5];
for(var key in powder){
for(var key2 in powder){
if(key == key2){ alert("con");continue; };
}
}
}
</script>
<body onload="funOne()"></body>
</html>
來源
2015-06-28 05:47:01
KDP
你想在這裏繼續? – adeneo
創建一個小提琴 –
@adneo第二個循環 – Fuzzyzilla