What is the purpose of switch-case

Posted by Jennifer | Updated on

The switch case statement in JavaScript is used for decision making purposes. In a few cases, using the switch case statement is going to be more convenient than if-else statements. The syntax would be as below,

The above multi-way branch statement provides an easy way to dispatch execution to different parts of code based on the value of the expression.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers