I am a frontend dev. JavaScript (well, TypeScript) is my bread and butter. Even knowing its quirks I never would have thought how inconsistent Date actually is. I encourage everyone to try this quiz.
This is what JavaScript haters should bring forth, not 0.1 + 0.2 !== 0.3!
There is a reason almost everyone use some Date lib, like Luxon and not the built in. And well, having a horrible built in lib that they can't change due to legacy code breaking is nothing really new or unique to JS.
Google tried to do that with Dart, and failed. In fairness Dart 1 was much worse than Dart 2... So maybe that was a good thing because there's no way they'd have been able to improve Dart as much as they have if it was part of the web.
Yes and no. Wasm has no "standard library" so if you wanted to use Dates, your wasm would need to have its own implemation bundled for when the user visits the page. Ditto for everything else including string support! As you can imagine having to ship all this basic functionality can bloat the wasm and slow page loads.
You also can't fully escape JS, as the only way wasm can interact with the page & browser are through the JS functions you write and make available to your wasm. I suppose you could take advantage of this to not have to ship your own standard library & use the JS Date implementation, but at that point why not just use JS?
Wasm has strengths but it's not suitable for replacing JS for everyday websites.
I mean, for what it's worth, I'm a seasoned dev and just did a run where I tried to answer everything as it makes sense to me (which is "throws an error" or "invalid date" for all of them) and I also got a score of 4/28.
...and two of those points were given to me, because the quiz interpreted my answer differently than I meant it.
In other words, this quiz exists to highlight that JavaScript's Date functions make no sense.
Great quiz. It teaches you the rules while training you to expect the unexpected, even in the rare cases that the rules are applied consistently.
I got exactly half the questions right.