continue keyword
continue; skips the rest of the current loop iteration and re-evaluates the loop condition (or moves to the next item for for ... of). Bangla form: চলুন;.
Note: continue only applies to loops. Inside a switch it passes through to the enclosing loop.
Syntax
continue;
Examples
Skip even numbers:
var i = 0;
while (i < 6) {
i = i + 1;
if (i % 2 == 0) { continue; }
print(i);
}
// 1
// 3
// 5
In a C-style for, the update clause still runs before the next iteration:
for (var k = 0; k < 5; k = k + 1) {
if (k == 2) { continue; }
print(k);
}
// 0
// 1
// 3
// 4
In for ... of, the loop advances to the next item:
for (var name of ["alice", "_skip", "bob"]) {
if (name.starts_with("_")) { continue; }
print(name);
}
// alice
// bob
continue inside a switch
continue does not match the enclosing switch. It propagates outward to the next enclosing loop:
for (var n of [1, 2, 3]) {
switch (n) {
case 2: { continue; } // skips n==2 in the outer for-of
default: { print(n); }
}
}
// 1
// 3
Bangla form
যতক্ষণ (p < 5) {
p = p + 1;
যদি (p == 2) { চলুন; }
print(p);
}