Interviewer: Can (a==1 && a==2 && a==3) Ever Evaluate to ‘true’ in JavaScript?

Yes, it can be true, and there are 6 ways — amazing!

fatfish
4 min readSep 18, 2023

--

Photo by Mikhail Vasilyev on Unsplash

Recently, I was asked a very interesting interview question: Can (a== 1 && a==2 && a==3) ever evaluate to true in JavaScript?. I almost lost the job opportunity because I couldn’t answer.

--

--

fatfish

Hi friends, I am a front-end engineer from Alibaba, let’s code happily together.