DEV Community

Discussion on: Is there a reason to use == over ===?

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

This is interesting. My gut reaction is that you should convert to the correct type ASAP, so you don't have to do it multiple times later.

But maybe the comparison before conversion is good so that you don't convert values you aren't going to use?

Still, I would do a comparison with ===, using a string representation of the number, rather than comparing to a number if that's the case.