天行健, 君子以自强不息
Sunny's Blog
Title

Item 5 - Avoid using == with Mixed Types

Effective 系列,每天一个Item,轻松提高JS

避免使用 ==

严格模式下也是要求用===的,因为==中含有了隐性的q强制类型转化,这里主要是把类型转化表show出来

               1.null == undefined  //true
               2.null/undefined == not null/undefined  //false
               3.原生的string/boolean/number == Date obj (先找toString,再找valueOf)
               4.原生的string/boolean/number == not Date obj (先找cvalueOf,再找toString)
               5.原生的string/boolean/number == 原生的string/boolean/number (转为number比较)
            
地势坤,君子以厚德载物