Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Human readable text about their differences</h2> <p>Using <code>!==</code> and <code>===</code> will do a more strict compare than <code>==</code>/<code>!=</code>. The former will check if the objects being compared are of the same type, as well as if the values matches.</p> <p>Using <code>==</code> will make it possible for an implicit cast to be made, see the below examples.</p> <pre><code>(0 == '0') // true (0 === '0') // false ('' == 0 ) // true, the string will implicitly be converted to an integer ('' === 0 ) // false, no implicit cast is being made </code></pre> <hr> <h2>What does the standard say?</h2> <blockquote> <h2>11.9.6 The Strict Equality Comparison</h2> <p>Algorithm The comparison x === y, where x and y are values, produces true or false. Such a comparison is performed as follows:</p> <ol> <li>If Type(x) is different from Type(y), return false.</li> <li>If Type(x) is Undefined, return true.</li> <li>If Type(x) is Null, return true.</li> <li><p>If Type(x) is Number, then</p> <p>a. If x is NaN, return false.</p> <p>b.If y is NaN, return false.</p> <p>c. If x is the same Number value as y, return true.</p> <p>d. If x is +0 and y is 0, return true.</p> <p>e. If x is 0 and y is +0, return true.</p> <p>f. Return false.</p></li> <li><p>If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions); otherwise, return false.</p></li> <li>If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.</li> <li>Return true if x and y refer to the same object. Otherwise, return false. NOTE This algorithm differs from the SameValue Algorithm (9.12) in its treatment of signed zeroes and NaNs.</li> </ol> </blockquote> <hr> <blockquote> <h3>11.9.3 The Abstract Equality Comparison Algorithm</h3> <p>The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows:</p> <ol> <li><p>If Type(x) is the same as Type(y), then</p> <p>a. If Type(x) is Undefined, return t rue.</p> <p>b. If Type(x) is Null, return true.</p> <p>c. If Type(x) is Number, then</p> <pre><code>1. If x is NaN, return false. 2. If y is NaN, return false. 3. If x is the same Number value as y, return true. 4. If x is +0 and y is 0, return true. 5. If x is 0 and y is +0, return true. 6. Return false. </code></pre> <p>d. If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions). Otherwise, return false.</p> <p>e. If Type(x) is Boolean, return true if x and y are both true or both false. Otherwise, return false. f. Return true if x and y refer to the same object. Otherwise, return false.</p></li> <li>If x is null and y is undefined, return true.</li> <li>If x is undefined and y is null, return true.</li> <li>If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).</li> <li>If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.</li> <li>If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.</li> <li>If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).</li> <li>If Type(x) is either String or Number and Type(y) is Object, return the result of the comparison x == ToPrimitive(y) .</li> <li>If Type(x) is Object and Type(y) is either String or Number, return the result of the comparison ToPrimitive(x) == y.</li> <li>Return false</li> </ol> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload