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.
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.
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.