Switches have the potential to be super powerful, the ability to let conditions fall through...
switch(state){case'foo':console.log('one');case'bar':console.log('two');break;default:console.log('three');}// When state === 'foo', 'one' and 'two' are logged
...means there are some complex logical flows that could achieved.
But the hidden complexity fall-through case statements add and the ease of missing them means it's far more likely you'll introduce hard to find bugs or regressions.
As a result, most coding styles either warn or actively disallow case statements without a break; statement at the end. Removing that ability removes the key differentiator of a switch statement and makes it a slightly more concise if..else if statement assuming you have a set of conditions checking the same variable for different values. Pretty niche!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Switches have the potential to be super powerful, the ability to let conditions fall through...
...means there are some complex logical flows that could achieved.
But the hidden complexity fall-through case statements add and the ease of missing them means it's far more likely you'll introduce hard to find bugs or regressions.
As a result, most coding styles either warn or actively disallow case statements without a
break;
statement at the end. Removing that ability removes the key differentiator of aswitch
statement and makes it a slightly more conciseif..else if
statement assuming you have a set of conditions checking the same variable for different values. Pretty niche!