JS Coding Questions Logo
JS Coding Questions
#223💼 Interview

What are the conventions to be followed for the usage of switch case

Advertisement

728x90

Below are the list of conventions should be taken care,

1. The expression can be of type either number or string.

2. Duplicate values are not allowed for the expression.

3. The default statement is optional. If the expression passed to switch does not match with any case value then the statement within default case will be executed.

4. The break statement is used inside the switch to terminate a statement sequence.

5. The break statement is optional. But if it is omitted, the execution will continue on into the next case.

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 53

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
223of476
What are the conventions to be followed for the usage of switch case | JSCodingQuestions.com