DEV Community

Pandademic
Pandademic

Posted on

how on earth does this work

was reading


so i tested this in the terminal via node:
([]+![])[![]+1].repeat(100).toUpperCase()
Enter fullscreen mode Exit fullscreen mode

and it worked!?!?!?!??!
image of results

probably a dumb question but how does that work?
pardon my javascript , but it looks like a mess of arrays repeated 100 times in uppercase

this is dumb.

and ridiclous.

mystifying.

but also kind funny.

Discussion (2)

Collapse
jonrandy profile image
Jon Randy

It's actually quite simple, it's just taking advantage of the implicit type conversions JS does behind the scenes. It is explained pretty well here

Collapse
pandademic profile image
Pandademic Author

thank you!