JS 제어문 (continue)
2021. 7. 16. 19:25
728x90

- continue 문은 루프 내에서 사용하여 해당 루프의 나머지 부분을 건너뛰고 바로 다음 표현식의 판단으로 넘어감
반복문 내에서 특정 조건에 대한 처리를 제외하고자 할 때 자주 사용
continue;

|
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>continue</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script>
for(i=1; i<=100; i++){
if(i % 2 == 0)
continue; //남아있는 코드를 무시하고 다음 반복으로 넘어감
document.write(i,"<br>");
}
document.write("<hr>");
</script>
</head>
<body>
</body>
</html>
|
cs |
728x90
'JavaScript > Study' 카테고리의 다른 글
| [JS] Date 객체 (new Date) (0) | 2021.07.20 |
|---|---|
| JS 조건문 (switch) (0) | 2021.07.16 |
| JS 조건문 (if 문) (0) | 2021.07.16 |
| JS 반복문 중첩 (for 문) (0) | 2021.07.16 |
| [JS] 반복문 중첩 (while 문) (0) | 2021.07.16 |



