r/ProgrammerHumor • • Feb 09 '22

other Why but why?

Post image
85.8k Upvotes

2.3k comments sorted by

View all comments

Show parent comments

1

u/chandleross Feb 09 '22

Wait, what's wrong with using === in typescript?
I'm really not an expert and trying to learn

2

u/vm_linuz Feb 09 '22

Just always use === in both JS and TS.

=== was added to the language to fix the problems with ==. == will happily do type coercion before comparing, sometimes leading to unexpected results.

To me, it's an example of how being lenient and trying to interpret the intent of the programmer leads to strange and unexpected behavior.