Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Why 0 = = "00" in js is equal to true; ; Is it absolute? If it is used to make judgments, will there be any problems?
Why 0 = = "00" in js is equal to true; ; Is it absolute? If it is used to make judgments, will there be any problems?
Js variables are not strictly typed. In js, 0 means integer 0, and "00" means string.

When comparing 0 = = "00", "00" is converted into an integer. Comparatively speaking, the conversion result is 0 == 0, which holds.

There is no problem with this judgment, but it is not recommended, which will have an impact on reading and modifying the code.