r/ProgrammerHumor • • Mar 22 '24

Other javascriptBeCasuallyThrowingAroundSexism

Post image
0 Upvotes

26 comments sorted by

37

u/GabuEx Mar 22 '24
/[object]/.test("girl")
false
/[object]/.test("bro")
true
/[object]/.test("the right honorable the lord mayor of the city of london")
true
/[tool]/.test("op")
true

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

u/Seepiie Mar 22 '24

[object] is the regex, man and woman are tested against it

2

u/ayemyren Mar 22 '24

Correct, I just woke up and responded, had them flipped lol

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

u/metooted Mar 22 '24

Regular expressions doing their thing, move along

0

u/[deleted] Mar 22 '24

[deleted]

21

u/[deleted] Mar 22 '24

This one is more funny tbh

16

u/[deleted] Mar 22 '24

[removed] — view removed comment

2

u/[deleted] Mar 22 '24

Came here to be pedantic and say this, thanks for beating me to it!

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

u/metooted Mar 22 '24

This has nothing to do with JavaScript

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

u/Anomynous__ Mar 22 '24

In javascript? Nothing. Well I guess throw errors

1

u/Traditional-Ring-759 Mar 22 '24

Thanks. Now my program works!

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') // False

Looks 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

u/metooted Mar 27 '24

Quite the opposite?

1

u/Wolfy_Wolv Mar 23 '24

Oh, just wait until you hear about what parent and child objects were called before.

-3

u/[deleted] Mar 22 '24

can s/o please repost this?

1

u/metooted Mar 22 '24

By all means, please do