S
8

Can we talk about why == and === behave differently in JavaScript?

I used == by mistake and it caused a MAJOR bug in my script.
3 comments

Log in to join the discussion

Log In
3 Comments
dylanfisher
The time I spent three whole days debugging because '0' == false evaluates to true. Ngl, string addition turning into concatenation feels like that same kind of sneaky type coercion mess. Honestly makes you just want to use triple equals for everything.
3
seth683
seth6831mo ago
Your major bug reminds me of when '2' + 2 gave me '22' instead of 4.
1
beth553
beth5531mo ago
Ugh, type coercion strikes again.
4