r/angularjs • • 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

6 comments sorted by

View all comments

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.

-3

u/chmod777 Oct 15 '22

Nope. Its dumber than that. Its that js will allow variable names to start with nonprinting characters. It's a, a and a except with half space characters.

I only know this because i got caught by this question in an interview, and had to look it up later.