Comment by Timwi
1 year ago
This sounds like you haven't dealt with much moderately complex code in JavaScript. It sounds like you've never run into a situation where innocuous-looking code like
if (isAuthenticated)
{
...
}
behaves strangely and it takes you hours to track down in debugging, only to find that somewhere else in the code, isAuthenticated was assigned an array and it was assumed it could be treated as a Boolean that would be false if and only if the array was empty. Turns out sometimes the value is [[]] and it gets treated as false unexpectedly.
In any reasonable language, even a dynamically typed one, this should just be a type error because it's not a Boolean, but JavaScript decides to do something almost certainly unwanted. This is the real source of the complaints, not the fact that you can write “[[]]==false” on the console and laugh at the results.
>only to find that somewhere else in the code, isAuthenticated was assigned an array
That isn't "moderately complex code", that's completely stupid code and you deserve the grief if you are willy-nilly setting a boolean as an array. Maybe learning the difference between a bool and an array is something you should have done earlier in your programming journey.
Also love how you assume I've never worked on "moderately complex code" as a slight on me, when I've been writing software for over 40 years - just because I don't do stupid shit like assigning an array to a boolean variable does not i dicate I've "never worked on moderately complex code". That's some kind of gatekeeping troll.
>any reasonable language
I'm really not sure how stupid you have to be to assign an array to isAuthenticated. No, it is not something I have ever done in any language, because I'm not an idiot. YMMV.
> This is the real source of the complaints,
The complaints come from people doing stupid shit to themselves. It was easily avoidable and they got mad at the language?? Should we blame the language for every stupid thing people do with it? Will you also blame English for letting you write an obviously stupid comment?