== (或者 !=) 操作在需要的情况下自动进行了类型转换。=== (或 !==)操作不会执行任何转换。===在比较值和类型时,可以说比==更快(jsPref)。

1
2
3
4
5
6
7
8
9
10
11
[10] ==  10      // 为 true
[10] === 10 // 为 false

'10' == 10 // 为 true
'10' === 10 // 为 false

[] == 0 // 为 true
[] === 0 // 为 false

'' == false // 为 true 但 true == "a" 为false
'' === false // 为 false