Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
What are the conventions to be followed for the usage of switch case?
Home
JavaScript
What are the conventions to be followed for the usage of switch case?
0
votes
asked
Oct 10, 2023
in
JavaScript
by
DavidAnderson
What are the conventions to be followed for the usage of switch case?
javascript-interview-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Oct 10, 2023
by
DavidAnderson
Below are the list of conventions should be taken care,
The expression can be of type either number or string.
Duplicate values are not allowed for the expression.
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.
The break statement is used inside the switch to terminate a statement sequence.
The break statement is optional. But if it is omitted, the execution will continue on into the next case.
...