Javatpoint Logo
Javatpoint Logo

JavaScript Switch

The JavaScript switch statement is used to execute one code from multiple expressions. It is just like else if statement that we have learned in previous page. But it is convenient than if..else..if because it can be used with numbers, characters etc.

The signature of JavaScript switch statement is given below.

Let’s see the simple example of switch statement in javascript.

Test it Now

Output of the above example

The switch statement is fall-through i.e. all the cases will be evaluated if you don't use break statement.

Let’s understand the behaviour of switch statement in JavaScript.

Test it Now

Output of the above example

undefined B Grade C Grade No Grade
Next TopicJavascript Loop





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA