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.
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?