kaqi 发表于 2013-1-29 08:59:08

javascript difference between == and ===

<blockquote>JavaScript has both strict andtype-converting equality comparison.For strict equality the objects beingcompared must have the same type and:
<ul>Two strings are strictly equal when they have the same sequence ofcharacters, same length, and samecharacters in corresponding positions.
Two numbers are strictly equal when they are numerically equal (havethe same number value). NaN is notequal to anything, including NaN.Positive and negative zeros are equalto one another.
Two Boolean operands are strictly equal if both are true orboth are false.
Two objects are strictly equal if they refer to the same Object.
Null and Undefined types are == (but not ===).

0==false   // true0===false// false, because they are of a different type1=="1"   // true, auto type coersion1==="1"    // false, because they are of a different type
<div class="logRow logRow-command">>>> new String("aa")===new String("aa")
页: [1]
查看完整版本: javascript difference between == and ===