When you put the continue
keyword in a for loop, execution jumps to the update expression (i++
in the example):
for (var i = 0; i < 3; i++) {
if (i === 1) {
continue;
}
console.log(i);
}
Expected output:
0
2
When you continue
in a while loop, execution jumps to the condition (i < 3
in the example):
var i = 0;
while (i < 3) {
if (i === 1) {
i = 2;
continue;
}
console.log(i);
i++;
}
Expected output:
0
2