JavaScript Examples The following examples show how to use antd#Switch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the si...
Example: switch with String Type Case Copy var str = "bill"; switch (str) { case "steve": alert("This is Steve"); case "bill": alert("This is Bill"); break; case "john": alert("This is John"); break; default: alert("Unknown Person"); break; } Try it...
Flowchart of JavaScript switch statement Example 1: Simple Program Using switch...case Suppose we want to display a message based on the current day of the week. Let's look at the example below to see how we can achieve this usingswitch...case. letday =3;letactivity;switch(day) {case1...
break statements indicate to the interpreter the end of that particular case. If they were omitted, the interpreter would continue executing each statement in each of the following cases We will explain the break statements in the LOOP Control chapter. Check Out JavaScript Tutorial ExampleFollowing ...
The basic JavaScript switch syntax: switch(expression){ case value: expression; break; case value: expression; break; default: Expression;} Following the logic of the example syntax, this sequence of events take place. The expression is evaluated ...
JavaScript Switch Statement Example <!-- your JavaScript goes here --> <!-- try changing the data in "value" and run --> var value=2; var message=''; switch(value){ case 1: message += "Value is 1."; break; case 2: message += "Value is 2."...
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
In JavaScript, you can also share code blocks between values. For example: // Set the TechOnTheNet technology to JavaScript var totn_technology = 'JavaScript'; switch (totn_technology) { case 'SQL': console.log('TechOnTheNet SQL'); break; case 'JavaScript': case 'HTML': console.log...
See example here: var foo = 0; switch (foo) { case -1: console.log('negative 1'); break; case 0: // foo is 0 so criteria met here so this block will run console.log(0); // NOTE: the forgotten break would have been here case 1: // no break statement in 'case 0:' so ...
This section provides a JavaScript tutorial example showing how to write a 'switch ... case' statement.© 2025 Dr. Herong Yang. All rights reserved.To help you understand how "switch ... case" statements work, I wrote the following the JavaScript tutorial example, Switch_Case_Statements.htm...