Merge pull request #2129 from vsemozhetbyt/ch-1-2-9

Address some possible inconsistencies in 1.2.9
This commit is contained in:
Ilya Kantor 2020-09-24 14:21:57 +03:00 committed by GitHub
commit 58ed032bf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -14,7 +14,7 @@ Some of the reasons:
1. Obviously, true. 1. Obviously, true.
2. Dictionary comparison, hence false. `"a"` is smaller than `"p"`. 2. Dictionary comparison, hence false. `"a"` is smaller than `"p"`.
3. Again, dictionary comparison, first char of `"2"` is greater than the first char of `"1"`. 3. Again, dictionary comparison, first char `"2"` is greater than the first char `"1"`.
4. Values `null` and `undefined` equal each other only. 4. Values `null` and `undefined` equal each other only.
5. Strict equality is strict. Different types from both sides lead to false. 5. Strict equality is strict. Different types from both sides lead to false.
6. Similar to `(4)`, `null` only equals `undefined`. 6. Similar to `(4)`, `null` only equals `undefined`.

View file

@ -9,9 +9,9 @@ In JavaScript they are written like this:
- Equals: `a == b`, please note the double equality sign `==` means the equality test, while a single one `a = b` means an assignment. - Equals: `a == b`, please note the double equality sign `==` means the equality test, while a single one `a = b` means an assignment.
- Not equals. In maths the notation is <code>&ne;</code>, but in JavaScript it's written as <code>a != b</code>. - Not equals. In maths the notation is <code>&ne;</code>, but in JavaScript it's written as <code>a != b</code>.
In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities. In this article we'll learn more about different types of comparisons, how JavaScript makes them, including important peculiarities.
At the end you'll find a good recipe to avoid "javascript quirks"-related issues. At the end you'll find a good recipe to avoid "JavaScript quirks"-related issues.
## Boolean is the result ## Boolean is the result
@ -57,7 +57,7 @@ The algorithm to compare two strings is simple:
4. Repeat until the end of either string. 4. Repeat until the end of either string.
5. If both strings end at the same length, then they are equal. Otherwise, the longer string is greater. 5. If both strings end at the same length, then they are equal. Otherwise, the longer string is greater.
In the examples above, the comparison `'Z' > 'A'` gets to a result at the first step while the strings `"Glow"` and `"Glee"` are compared character-by-character: In the examples above, the comparison `'Z' > 'A'` gets to a result at the first step while the strings `'Glow'` and `'Glee'` are compared character-by-character:
1. `G` is the same as `G`. 1. `G` is the same as `G`.
2. `l` is the same as `l`. 2. `l` is the same as `l`.