JS and frontend are terrible and you'll hear this loudest from frontend people themselves. It's an entire industry built purely around the inertia of an unexpectedly wildly successful product.
To accommodate the greater scope of the web the language has evolved. It's fast, supports multiple paradigms, and never makes breaking changes, so your code will run the same 20 years from now.
Put another way: Systems with great benefits are able to survive their great failings.
This dynamic explains most "inexplicable" situations where something seemingly terrible in certain specific ways enjoys continued success.
But only if you can get it to work in all browsers and derivatives today, including their versions of the last 20 years.