You need to dive into the V8 code to figure it out. Actually this kind of thing gives you a greater appreciation for how JS works behind the scenes and not just believing it's "magic"
which is why you use a language that catches these stupid issues as early as possible [read: statically typed], instead of a language that just tries to ignore errors
You're confusing dynamic typing with weak typing / implicit casts.
The former can make writing code faster (at the cost of making maintenance more difficult), while the latter is a pretty questionable language design choice. Combine them, and you've got a disaster coming your way.
317
u/Stummi Mar 19 '24
I had to check it myself and its true. But ... why?
Edit: I guess its because the "smart" casting system and you create a
RegExp("[object Object]"), right?468
u/MojitoBurrito-AE Mar 19 '24
doesn't work in British JavaScript
258
u/Attileusz Mar 19 '24
You've heard of undefined behaviour. Now get ready for fatherless behaviour.
59
u/static_func Mar 19 '24
So women are objects to JavaScript
49
u/lxpnh98_2 Mar 19 '24
Finally, the answer to the age old question. Male should be 0 and female should be 1.
78
u/Its1mple Mar 19 '24
JavaScript is truly a sight to behold.
9
u/sagetraveler Mar 20 '24
Looks more like a failed paternity test, time for a heart to heart discussion with your mom.
7
u/aznalex Mar 20 '24
It’s JS for JerrySpringer not JavaScript
18
u/FlashBrightStar Mar 19 '24
When you realize that undefined behaviour is defined.
17
u/Faholan Mar 19 '24
Well, Object may be a "mom" and not a "dad", but Object is also a "boy" and not a "girl". Transgender object ?
1
u/Meeky00 Mar 20 '24
What app is this screenshot from? Looks like an iPad app 🤔
3
u/Fat_Burn_Victim Mar 20 '24
JS is a romance language confirmed
1
u/friedcouch Mar 20 '24
What app is this?
-1
u/[deleted] Mar 20 '24
be careful, people are going to say the variable identifies as a string, not a boolean or that it’s strict type fluid 😂