Merge pull request #354 from brentguf/comparisons

Comparisons chapter
This commit is contained in:
Ilya Kantor 2018-02-03 15:55:03 +03:00 committed by GitHub
commit 8b8f3f6d86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@ Many comparison operators we know from maths:
- Greater/less than: <code>a &gt; b</code>, <code>a &lt; b</code>. - Greater/less than: <code>a &gt; b</code>, <code>a &lt; b</code>.
- Greater/less than or equals: <code>a &gt;= b</code>, <code>a &lt;= b</code>. - Greater/less than or equals: <code>a &gt;= b</code>, <code>a &lt;= b</code>.
- Equality check is written as `a == b` (please note the double equation sign `'='`. A single symbol `a = b` would mean an assignment). - Equality check is written as `a == b` (please note the double equation sign `=`. A single symbol `a = b` would mean an assignment).
- Not equals. In maths the notation is <code>&ne;</code>, in JavaScript it's written as an assignment with an exclamation sign before it: <code>a != b</code>. - Not equals. In maths the notation is <code>&ne;</code>, in JavaScript it's written as an assignment with an exclamation sign before it: <code>a != b</code>.
[cut] [cut]
@ -108,7 +108,7 @@ From JavaScript's standpoint that's quite normal. An equality check converts usi
## Strict equality ## Strict equality
A regular equality check `"=="` has a problem. It cannot differ `0` from `false`: A regular equality check `==` has a problem. It cannot differ `0` from `false`:
```js run ```js run
alert( 0 == false ); // true alert( 0 == false ); // true
@ -146,7 +146,7 @@ There's a non-intuitive behavior when `null` or `undefined` are compared with ot
For a strict equality check `===` For a strict equality check `===`
: These values are different, because each of them belong to a separate type of it's own. : These values are different, because each of them belongs to a separate type of its own.
```js run ```js run
alert( null === undefined ); // false alert( null === undefined ); // false