r/ProgrammerHumor • • Mar 20 '24

Meme areJSDevsActuallySane

Post image
14k Upvotes

554 comments sorted by

View all comments

Show parent comment

18

u/Lumethys Mar 20 '24

new RegExp({})

      |

      ↓

new RegExp([object Object])

      |

      ↓

new RegExp('[object Object]')

5

u/AbsolutelyFreee Mar 20 '24

This is fucking absurd

10

u/Cley_Faye Mar 20 '24

The middle step is wrong. {} is directly converted to a string with {}.toString(), which indeed results in [object Object]. Writing new RegExp([object Object]) is incorrect.

13

u/Lumethys Mar 20 '24

It is like a thought flow, not a compiling step. Or else I would just write the whole OP post back