minor fixes

This commit is contained in:
Ilya Kantor 2019-07-26 23:21:49 +03:00
parent 689975093c
commit f6ff773033
24 changed files with 67 additions and 76 deletions

View file

@ -3,11 +3,11 @@
```js no-beautify
5 > 4 → true
"apple" > "pineapple" → false
"2" > "12" → true
undefined == null → true
undefined === null → false
"2" > "12" → true
undefined == null → true
undefined === null → false
null == "\n0\n" → false
null === +"\n0\n" → false
null === +"\n0\n" → false
```
Some of the reasons:
@ -17,5 +17,5 @@ Some of the reasons:
3. Again, dictionary comparison, first char of `"2"` is greater than the first char of `"1"`.
4. Values `null` and `undefined` equal each other only.
5. Strict equality is strict. Different types from both sides lead to false.
6. See (4).
6. Similar to `(4)`, `null` only equals `undefined`.
7. Strict equality of different types.

View file

@ -74,7 +74,7 @@ alert( '2' > 1 ); // true, string '2' becomes a number 2
alert( '01' == 1 ); // true, string '01' becomes a number 1
```
For boolean values, `true` becomes `1` and `false` becomes `0`.
For boolean values, `true` becomes `1` and `false` becomes `0`.
For example:
@ -138,11 +138,8 @@ The strict equality operator is a bit longer to write, but makes it obvious what
## Comparison with null and undefined
Let's see more edge cases.
There's a non-intuitive behavior when `null` or `undefined` are compared to other values.
For a strict equality check `===`
: These values are different, because each of them is a different type.