Why Would I Need to Use a Switch Statement?

Several of the languages I’ve learnt have switch statements, which do the same thing as if/else if/else statements without saving too much typing as far as I’ve noticed and being slightly less intuitive. Is there a reason why switch statements are better for any circumstance?

Some older languages use it because it translates into specific machine code patterns.

Some newer languages use them, or similar things, for making comparisons on structure of values.

js does neither so uh no not really
consider using an object for the options instead

2 Likes

Thank you! :grinning: