1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-02-24 19:42:51 +01:00

Update JavaScript switch statement (#2161)

add syntax highlighting in code snippet.
This commit is contained in:
puru-khedre 2022-10-12 19:14:53 +05:30 committed by GitHub
parent b6818a42ea
commit 7af71de4f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,9 @@
# Switch # Switch Case
The `switch` statement evaluates an expression, matching the expression's value against a series of `case` clauses, and executes statements after the first `case` clause with a matching value, until a `break` statement is encountered. The `default` clause of a `switch` statement will be jumped to if no `case` matches the expression's value. The `switch` statement evaluates an expression, matching the expression's value against a series of `case` clauses, and executes statements after the first `case` clause with a matching value, until a `break` statement is encountered. The `default` clause of a `switch` statement will be jumped to if no `case` matches the expression's value.
``` ## Example
```js
switch (expression) { switch (expression) {
case value1: case value1:
//Statements executed when the result of expression matches value1 //Statements executed when the result of expression matches value1
@ -22,4 +23,4 @@ switch (expression) {
<ResourceGroupTitle>Free Content</ResourceGroupTitle> <ResourceGroupTitle>Free Content</ResourceGroupTitle>
<BadgeLink colorScheme='blue' badgeText='Read' href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch'>switch - MDN</BadgeLink> <BadgeLink colorScheme='blue' badgeText='Read' href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch'>switch - MDN</BadgeLink>
<BadgeLink colorScheme='blue' badgeText='Read' href='https://javascript.info/switch'>The switch statement</BadgeLink> <BadgeLink colorScheme='blue' badgeText='Read' href='https://javascript.info/switch'>The switch statement - javascript.info</BadgeLink>