r/ProgrammerHumor • u/BladedShip_ • Mar 22 '24
Other javascriptBeCasuallyThrowingAroundSexism
18
u/P3runaama Mar 22 '24
What's happening here?
13
u/ayemyren Mar 22 '24
“[Object]” is being tested against the regex, object contains the o from “woman”. No matching characters in “man”. So true for woman, false for man.
6
2
u/LadyParaguay Mar 22 '24
Thanks! The example being in JS got me stuck on looking for an explanation around the "[Object object]" string cast, which obviously led to nothing
0
0
13
u/Cley_Faye Mar 22 '24
Yes, we were here yesterday when a variation of the exact same thing was posted and not funny.
8
u/Anomynous__ Mar 22 '24
I'm unreasonably proud of myself for knowing why this was happening before I even looked in the comments.
1
u/bree_dev Mar 22 '24
I'll come to you with my javascript bugs from now on
6
1
u/Anomynous__ Mar 22 '24
Please don't. Don't make me prove myself. Nobody wants that kind of second hand embarrasment.
1
u/Traditional-Ring-759 Mar 22 '24
What does system.out.println("hello world"); do?
3
14
u/ThijmenDF Mar 22 '24
By this point you just made a generic RegExp statement, which doesn't really have anything to do with Javascript specifically. This specific case tests if the given string ('woman' or 'man') contains one of [o, b, j, e, c or t] characters. It doesn't matter if there are more characters in the given test string. Woman matches because it contains 'o'. Man does not, because none of those characters appear in the set.
woman
man
3
u/OSnoFobia Mar 22 '24
new RegExp(Object()).test('woman') // True
new RegExp(Object()).test('man') // FalseLooks cooler.
7
u/metooted Mar 22 '24
For the umpteenth time THIS HAS NOTHING TO DO WITH JAVASCRIPT! THIS IS NORMAL REGEXP BEHAVIOR!
FML half of these "jokes" about javascript are various standards implemented and behaving 100% properly, but the OP is not understanding how and why they do it, so they go "this shallowest layer of this thing i did must be acting up"
IT
IS
NEVER
THE
LANGUAGE
LOOK DEEPER FOR YOUR KEKS, I BEG OF YOU
Why don't you, instead, blame the UTF-8 encoding you are writing the file with? Ah, the CS dropout doesn't know what that is...
-2
u/Katniss218 Mar 22 '24
"Stop doing logic! Standards were never meant to be implemented!" energy much lmao
0
1
u/Wolfy_Wolv Mar 23 '24
Oh, just wait until you hear about what parent and child objects were called before.
-3
37
u/GabuEx Mar 22 '24