Skip to content

Instantly share code, notes, and snippets.

@qti3e
Created March 27, 2018 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qti3e/fefcf0704df82d57744c59a7bf487c31 to your computer and use it in GitHub Desktop.
Save qti3e/fefcf0704df82d57744c59a7bf487c31 to your computer and use it in GitHub Desktop.
Why break in a switch statement is important?
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