Control Flow

If

if (cond1) {
    // ...
} else if (cond2) {
    // ...
} else {
    // ...
}

Switch

switch (x) {
    case 0: // switch-case uses a === match
        // ...
        break;
    case 1:
    case 2: // in JS, the code block can be shared between cases like C
        // ...
        break;
    // ...
    default:
        // ...
}

For

For-in

For-in loops over properties of an object.

For-of

For-of loops over values of an iterable object.

Reference

[1] https://www.w3schools.com/js/js_loop_forin.asp

Last updated

Was this helpful?