343
submitted 1 year ago* (last edited 1 year ago) by theory@lemmy.world to c/programmer_humor@programming.dev

Explanation: it's mostly due to how js does type conversion. for the Ls, it's

[] is an empty array ![] is treated as false combining a boolean with the empty array returns "false" as a string (so true + [] = "true", false + [] = "false") ! + [] is treated as true ! + [] + ! + [] is treated as 2 since true + true = 1 + 1 = 2 so you have "false"[2], which is l for the o it's [] is an empty array [] + {} returns "[object Object]" as a string ({} + [] returns 0) ![] is false !![] is true +!![] casts it to an integer so that part is "[object Object]"[1], which returns "o"

you are viewing a single comment's thread
view the rest of the comments
[-] Haus@kbin.social 3 points 1 year ago

That reads remarkably like a Whitehead theorem in Principia Mathematica.

this post was submitted on 19 Jul 2023
343 points (97.2% liked)

Programmer Humor

19594 readers
839 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS