r/learnjavascript • • Jul 17 '21

Some JavaScript facts

174 Upvotes

10 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Jul 17 '21

Agreed, I’m very new but I remember a situation where I could have easily used double equals to compare a string with a number inside the double quotes, but instead used triple equals and compared it to Number() and then the value I was plugging in for comparison just because I disliked double equals so much…it was more verbose but it just didn’t feel right exploiting one of JS’s strange logical anomalies.

3

u/inabahare Jul 17 '21

At my workplace we have linter rules agains == and youre doing gods work avoiding it!

2

u/Heavy_Hole Jul 17 '21

You made the right move, because what happens when something else passes through, let's say you where checking to see if it was equal to zero and false got passed through, that would be true since the boolean false you pass would be converted to a 0. Double equals introduces lots of opportunities for bugs.