this post was submitted on 14 Apr 2024
329 points (94.3% liked)
linuxmemes
20880 readers
10 users here now
I use Arch btw
Sister communities:
- LemmyMemes: Memes
- LemmyShitpost: Anything and everything goes.
- RISA: Star Trek memes and shitposts
Community rules
- Follow the site-wide rules and code of conduct
- Be civil
- Post Linux-related content
- No recent reposts
Please report posts and comments that break these rules!
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Want to print out all odd numbers from 1 to 100? Easy:
for(_=[];_<+!![]+""+[]*[]+[]*[];_++)(_%+(!![]+!![])?console.log(_):[]);
Actually, I prefer this one:
for(_=[];_<+!![]+""+[]*[]+[]*[];_++%+(!![]+!![])?[]:console.log(_));
Or this one without the "undefined" when run in a browser console:
for(_=[];_<+!![]+""+[]*[]+[]*[]-!![]-!![];_++%+(!![]+!![])?[]:console.log(_));_+!![]
Wtf people, can somebody explain?
_ is a variable name, [] becomes 0 when converted to an integer, !![] becomes 1. The + "" + means that the integers 1, 0, 0 get converted to a string - "100", which gets converted back to an integer because it's in the for loop. And there's various other horrible conversions going on to make it all work.