Completely agree, it's like writing readable prose, understand your audience.
That said, give me proper pattern matching in JS. Hard to live with languages that haven't caught up yet.
I really want this. Along with switch being as expression. Seems like something that JavaScript is obviously missing.
Unfortunately JavaScript still hasn't caught up with CoffeeScript.
Even PHP has this now, albeit with a different keyword (match) due to existing switch semantics being pretty bad
I agree that overly clever code is always to be avoided. But is this really overly clever? I wouldn't expect an engineer early in their career necessarily to understand on sight what it does. But I might worry a little for one who couldn't figure it out through experiment.
[edit: fixed typo]
Additionally, doesn't this somewhat also bring in the methodology of dealing with the error cases first?
You're going to hate your former cleverness then.
That's what the oncall bonus pay is for.
This pattern isn't "cleverness", it's just a readability-improving trick that's cheap to figure out. The hundred seconds you spend on it seeing it for the first time is a one-time cost.
That said, this isn't some kind of high-level hackery. If it's cleaner than if/else if chain, you should use it.
Programming is a profession. A professional is expected to learn and grow. The right answer to seeing a code construct one doesn't understand isn't throwing hands up in the air, but spending the few minutes necessary to figure out what it does.