Skip to content
Sign upLog in
← Back to Community

Javascript - (a==1 && a==2 && a==3) returns true?

Profile icon
Babbel

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

Voters
Profile icon
alfredobustos
Profile icon
khang
Profile icon
amasad
Profile icon
timmy_i_chen
Profile icon
Babbel
Comments
hotnewtop
Profile icon
amasad

1

Profile icon
timmy_i_chen

Clever - I like it!

Profile icon
Babbel

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

Profile icon
timmy_i_chen

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

Cannot infer image mime type

Profile icon
Babbel

@timmy_i_chen oh yeah, js is very weird ^^

Profile icon
LiamChurchill

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

Profile icon
Babbel

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