DEV Community

Pandademic
Pandademic

Posted on

4 2

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.

Top comments (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 β€’

thank you!

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay