Skip to content

Commit 070ed39

Browse files
bence98denysdovhan
andauthored
fix: Merge two Math.max()<Math.min() entries #230 (#231)
* Merge two `Math.max()<Math.min()` entries #230 * chore: fix formatting Co-authored-by: Denys Dovhan <denysdovhan@gmail.com>
1 parent 2be9310 commit 070ed39

File tree

1 file changed

+20
-35
lines changed

1 file changed

+20
-35
lines changed

README.md

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ Currently, there are these translations of **wtfjs**:
113113
- [Default behavior Array.prototype.sort()](#default-behavior-arrayprototypesort)
114114
- [resolve() won't return Promise instance](#resolve-wont-return-promise-instance)
115115
- [`{}{}` is undefined](#-is-undefined)
116-
- [`min` is greater than `max`](#min-is-greater-than-max)
117116
- [`arguments` binding](#arguments-binding)
118117
- [An `alert` from hell](#an-alert-from-hell)
119118
- [An infinite timeout](#an-infinite-timeout)
@@ -1723,17 +1722,32 @@ See for reference `NOTE 2` on the ECMA-262 definition for `toFixed`.
17231722

17241723
## `Math.max()` less than `Math.min()`
17251724

1725+
I find this example hilarious:
1726+
17261727
```js
1727-
Math.min(1, 4, 7, 2); // -> 1
1728-
Math.max(1, 4, 7, 2); // -> 7
1729-
Math.min(); // -> Infinity
1730-
Math.max(); // -> -Infinity
17311728
Math.min() > Math.max(); // -> true
1729+
Math.min() < Math.max(); // -> false
17321730
```
17331731

17341732
### 💡 Explanation:
17351733

1736-
- [Why is Math.max() less than Math.min()?](https://charlieharvey.org.uk/page/why_math_max_is_less_than_math_min) by Charlie Harvey
1734+
This is a simple one. Let's consider each part of this expression separately:
1735+
1736+
```js
1737+
Math.min(); // -> Infinity
1738+
Math.max(); // -> -Infinity
1739+
Infinity > -Infinity; // -> true
1740+
```
1741+
1742+
Why so? Well, `Math.max()` is not the same thing as `Number.MAX_VALUE`. It does not return the largest possible number.
1743+
1744+
`Math.max` takes arguments, tries to convert the to numbers, compares each one and then returns the largest remaining. If no arguments are given, the result is −∞. If any value is `NaN`, the result is `NaN`.
1745+
1746+
The opposite is happening for `Math.min`. `Math.min` returns ∞, if no arguments are given.
1747+
1748+
- [**15.8.2.11** Math.max](https://262.ecma-international.org/5.1/#sec-15.8.2.11)
1749+
- [**15.8.2.11** Math.min](https://262.ecma-international.org/5.1/#sec-15.8.2.12)
1750+
- [Why is `Math.max()` less than `Math.min()`?](https://charlieharvey.org.uk/page/why_math_max_is_less_than_math_min) by Charlie Harvey
17371751

17381752
## Comparing `null` to `0`
17391753

@@ -1906,35 +1920,6 @@ if (true) {
19061920

19071921
Surprisingly, it behaviors the same! You can guess here that `{foo: 'bar'}{}` is a block.
19081922

1909-
## `min` is greater than `max`
1910-
1911-
I find this example hilarious:
1912-
1913-
```js
1914-
Math.min() > Math.max(); // -> true
1915-
Math.min() < Math.max(); // -> false
1916-
```
1917-
1918-
### 💡 Explanation:
1919-
1920-
This is a simple one. Let's consider each part of this expression separately:
1921-
1922-
```js
1923-
Math.min(); // -> Infinity
1924-
Math.max(); // -> -Infinity
1925-
Infinity > -Infinity; // -> true
1926-
```
1927-
1928-
Why so? Well, `Math.max()` is not the same thing as `Number.MAX_VALUE`. It does not return the largest possible number.
1929-
1930-
`Math.max` takes arguments, tries to convert the to numbers, compares each one and then returns the largest remaining. If no arguments are given, the result is −∞. If any value is `NaN`, the result is `NaN`.
1931-
1932-
The opposite is happening for `Math.min`. `Math.min` returns ∞, if no arguments are given.
1933-
1934-
- [**15.8.2.11** Math.max](https://262.ecma-international.org/5.1/#sec-15.8.2.11)
1935-
- [**15.8.2.11** Math.min](https://262.ecma-international.org/5.1/#sec-15.8.2.12)
1936-
- [Why is `Math.max()` less than `Math.min()`?](https://charlieharvey.org.uk/page/why_math_max_is_less_than_math_min)
1937-
19381923
## `arguments` binding
19391924

19401925
Consider this function:

0 commit comments

Comments
 (0)