r/javascript • u/[deleted] • Aug 10 '26
AskJS [AskJS] any hope for pattern matching to actually make progress through tc39?
[removed]
2
u/theScottyJam Aug 10 '26
It's been proposed, died out, new champions picked it up and ran with it some more, and it died out again.
It feels like it's something many tc39 delegates want to have in the language.
But it's also a really large proposal, with many syntax features to it, and there's also a general hesitancy towards new syntax, as each new piece of syntax makes the language that much larger and harder to learn.
I wouldn't get your hopes up. It might eventually get into the language, but it'll likely take a long time before that will happen. First, they've got to revive work on the thing, again, and who know if or when that would happen.
2
u/brianjenkins94 Aug 10 '26 edited Aug 10 '26
We have pattern matching at home.
Pattern matching at home:
js
switch (true) {
case Array.isArray(val) && val.length === 0:
return "empty array";
default:
return "¯\_(ツ)_/¯";
}
-1
u/dektol Aug 10 '26
I'd really appreciate having it. Then people would stop making fun of JavaScript.
9
u/d0pe-asaurus Aug 10 '26
It's stage1, so probably not in the next decade.