Pattern matching in JavaScript
summary
Explains why switch statements in JavaScript are problematic: fallthrough can trigger multiple cases, case clauses are evaluated early causing runtime errors from missing globals and hidden shared state, and Redux reducers can break when actions lack expected fields. Compares alternatives such as chained if/else, nested ternaries, and an object-of-functions reducer pattern that defers evaluation, and points to a language-level solution via the TC39 Stage 1 pattern-matching proposal with Elixir/Rust-style matches and a macro playground for experimentation.
AI-written summary · about
chapters (6)
related talks
28mPattern Matching in JS
01mEstruturas condicionais do JavaScript
52mJavaScript Design Patterns
34mFunctional JavaScript for everyone
54mPatterns for Programming in JavaScript
53mMaintainable JavaScript with Functional Patterns
26mBack to the Future of JS II
49mA Skeptics guide to functional style javascript
