Switch statement

The switch statement selects instructions from a list of case statements.

TypeScript can help you write switch statements and ensure that all cases are handled.

Loading TypeScript...

Notice that if you change the value to a string, it performs both console.log statements. Until a switch statement encounters a break statement, it will continue to perform the instructions of each subsequent case.

Loading TypeScript...

Was this page helpful?