Created
March 27, 2018 10:34
-
-
Save qti3e/fefcf0704df82d57744c59a7bf487c31 to your computer and use it in GitHub Desktop.
Why break in a switch statement is important?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const o = { | |
i: 0, | |
get x() { | |
return this.i++; | |
} | |
}; | |
switch (o.x) { | |
case 0: | |
console.log("a"); | |
case 1: | |
console.log("b"); | |
case 2: | |
console.log("c"); | |
case 3: | |
case 4: | |
console.log("d"); | |
case 5: | |
console.log("e"); | |
break; | |
case 6: | |
console.log("You're not gonna see this."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment