Instantly share code, notes, and snippets.

Embed
What would you like to do?
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