Share your repls and programming experiences

← Back to all posts
Javascript - (a==1 && a==2 && a==3) returns true?
Babbel (65)

https://repl.it/@Babbel/JavascriptMagicalIf
This code shows how (a==1 && a==2 && a==3) can return true.

Comments
hotnewtop
Babbel (65)

@timmy_i_chen thanks, but i didn't find out this by myself. I saw it somewhere on the internet

timmy_i_chen (1180)

@Babbel reminds me a bit of this equality chart - JS is such a great but wonky language ;)

https://storage.googleapis.com/replit/images/1530030251561_a369916bdd7407fa5858913af49ca2e3.pn

Babbel (65)

@timmy_i_chen oh yeah, js is very weird ^^

LiamChurchill (3)

@Babbel Most likely off a Stack Overflow post with the title like "Can (a==1 && a==2 && a==3) be true?"

Babbel (65)

@LiamChurchill I saw it in a YouTube video and the YouTuber found it on a website. But I can't remember the address anymore