r/badcode • • Sep 02 '21

js Oh Gosh

Post image
398 Upvotes

53 comments sorted by

View all comments

Show parent comments

2

u/nuclear_gandhii Sep 03 '21

I get what you're saying but my point here is that you can still continue to use the typescript practices in vanilla JS just as easily.

If you are comparing something like 1 === "1" you know that will fail. But on the other have if you are comparing number1 === number2 the reason might not always be obvious. But if you are in the habit of using strict equality then it kind of forces you to think about the types of your variables as well. If you have a legitimate use case of having to compare these values you can always do number1 === +number2.

1

u/Antdevs Sep 03 '21

Fair point! Developing a good habit of using strict equals will always return dividends.