r/ProgrammerHumor • • Mar 20 '24

Meme areJSDevsActuallySane

Post image
14k Upvotes

554 comments sorted by

View all comments

2

u/GoodEfficiency8472 Mar 20 '24

I know nothing about JavaScript, perhaps that's why I can't see square brackets in the initial question?

3

u/Andersmith Mar 20 '24

as always with these posts, the secret is implicit type coercion. {} converted to a string is "[object Object]". Regex expects a string. JS makes sure it gets one by feeding the console log representation of whatever garbage non-string data you gave it.

1

u/damned_truths Mar 20 '24

That's what I thought initially, but I think they come from the "[object Object]" part.