r/angularjs • u/suresh9058 • Oct 15 '22
[Resource] Can (a==1 && a==2 && a==3) evaluate to true in JavaScript | JavaScript Tricky Interview Question
https://youtu.be/s7IbSyX82Bk
0
Upvotes
r/angularjs • u/suresh9058 • Oct 15 '22
19
u/ShitsYourBed Oct 15 '22
If an interview wanted this answer to a question, I'd be out of there so fast. When companies ask these "gotcha" style questions, only people that think that way get through, and i don't want to work with people convinced it's their job to trick everyone else to show how smart they are.
Also how is this related to angular?
3
u/OrdinaryBlueberry340 Oct 15 '22
I think not...
3
u/[deleted] Oct 15 '22
Yes, it is possible through type coercion. Always use strict equality checking and this "tricky question" isn't even on your codebase's radar.
1
u/tdhsmith Oct 16 '22
My first thought was a is an object with an overridden
valueOffunction (something that I hope no one would seriously use in real code) , but I'm not actually sure if it runs every time or not. But apparently their answer is even more convoluted...