4 ms·
`==` and `!=` are still quite handy when you don't want to deal with the distinction between `null` and `undefined`, which is almost always what you want.
by wk_end 3y ago
`==` and `!=` are still quite handy when you don't want to deal with the distinction between `null` and `undefined`, which is almost always what you want.
- kokanee 3y agoIf you do this, you need to think through all the possible types for the comparators and how type coercion will affect the expression. For example, `0 == ''`, `[] == ''`, and `[] != []` are all `true`. If you're using typescript to get guarantees about the input types, maybe that's a good use case for using type coercion intentionally.
- nerdwaller 3y agoI find that I really appreciate the explicit rather than the implicit comparisons (requiring `===` in js), especially picking up a new program or coming back to one after some time away. I view it like a database - do I really want multiple ways to show a value is empty? For something like a Boolean you have: `false`, `true` and `null` as valid values (trilean?) that now have to be handled.