B) Regardless, it is a perk of JS to be predictable. Suddenly throwing errors that say the number 244 does not contain "2" nor "\d" because we forgot to toString() because of a type mismatch would be cumbersome.
Ah, yes, esoteric knowledge that 3 ppl on the planet would know. Such predictable. Do you think predictable means the language can execute code or? I'd call you stupid, but seeing as how you think errors are unpredictable behavior, and all the down votes haven't clued you in, I doubt I could get the point across
This is the kind of nonsense that comes from people who accidentally choose the wrong side in a debate but can't admit when they're wrong. They just end up looking dumb.
If someone wants JS to be a different language than what it is, why not use a different language?
When you know you have no argument, but you can't admit you have no argument.
"If you hate this country so much, just move!"
We're allowed to criticize things. Whether we use them or not, whether we switch to something else or not.
If this were a discussion about comparing various programming languages or a green-field project, then maybe that would be an appropriate time to suggest a more appropriate language.
But really, every programming language will have some quirks.
If it's not already a string, it should (logically) not be coerced into a string
Any language that does not conform to your logic is "wrong", ergo for all languages to be acceptable, they must meet your crtieria, and it follows they would be equivalent to each other.
That's the trick, it always makes sense once it's explained. How long would it take you to reason towards that explanation on your own? You'd need to know how objects are coerced to string and how square brackets work in regex. And where to start looking.
And like I'm a big advocate for basic regex competency, which I do feel this falls under. But also in my experience most devs don't have basic regex competency.
View all comments
Show parent comment
-3
u/Exaskryz Mar 20 '24
If I had a number, I'd be confused that it didn't go to string though when I regExp for a digit.