break和continue


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>break</title>
</head>

<body>
</body>

</html>
<script>
for(i = 0; i < 9; i++) {
if(i == 5) {
break
}
document.write(i + '/')
// 0/1/2/3/4/
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>continue</title>
</head>

<body>
</body>

</html>
<script>
for(i = 0; i < 9; i++) {
if(i == 5) {
continue
}
document.write(i + '/')
// 0/1/2/3/4/6/7/8/
}
</script>