0 votes
in JavaScript by
What are the conventions to be followed for the usage of switch case?

1 Answer

0 votes
by

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.
...