DEV Community 👩‍💻👨‍💻

Discussion on: I've never become overly convinced that switch statements are that much cleaner than `if else if else if else if else`

jckuhl profile image
Jonathan Kuhl

I hate switch. And I hate that most languages make fallthrough the default behavior for switch. I love that Swift decided to instead implement a "fallthrough" keyword, because I find that fallthrough is the cause of 99% of most switch problems.

In JavaScript, I find using objects is a good alternative most the time.

const days {
  monday: "Monday";
  tuesday: "Tuesday";
  // . . . etc

const today = days[monday];
Enter fullscreen mode Exit fullscreen mode