continue 문
continue문은 반복문에서만 사용할 수 있습니다. while문에서 사용할 경우 continue문 다음에 오는 코드는 무시하고 바로 조건식으로 이동해 조건 검사를 합니다.
continue 문
for(초깃값; 조건식; 증감식){ continue; 실행코드 }
var 변수 = 초깃값; while(조건식){ continue; 실행문; 증감식; }
for 문 사용
for(let i=1; i<=10; i++){
if( i == 6 ){
continue;
}
document.write(i,"<br>");
}
/* 결과
1
2
3
4
5
7
8
9
10
*/while 문 사용
Last updated
Was this helpful?