summaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-06-07 17:42:59 +0200
committerJo-Philipp Wich <jo@mein.io>2021-06-07 18:19:41 +0200
commit86fb1300a500f6f49f1c6bb4f68c111106c862a5 (patch)
tree8a40fb958ed9d86eb5d449e7099848fd4819bc7d /README.md
parent3e893e68e33651067a77ff4ceeb8bb28020376dc (diff)
lib: implement min() and max() functions
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'README.md')
-rw-r--r--README.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/README.md b/README.md
index 929d261..0d98fd1 100644
--- a/README.md
+++ b/README.md
@@ -1192,3 +1192,37 @@ file path.
If `depth` exceeds the size of the call stack, the function returns `null`
as well.
+
+#### 6.60. `min([val1 [, val2 [, ...]]])`
+
+Return the smallest value among all parameters passed to the function.
+The function does a `val1 < val2` comparison internally, which means that
+the same value coercion rules as for relational operators apply. If both
+strings and numbers are passed to `min()`, then any string values will be
+effectively ignored since both `1 < "abc"` and `1 > "abc"` comparisons
+yield false results.
+
+```javascript
+min(5, 2.1, 3, "abc", 0.3); // 0.3
+min(1, "abc"); // 1
+min("1", "abc"); // "1"
+min("def", "abc", "ghi"); // "abc"
+min(true, false); // false
+```
+
+#### 6.61. `max([val1 [, val2 [, ...]]])`
+
+Return the largest value among all parameters passed to the function.
+The function does a `val1 > val2` comparison internally, which means that
+the same value coercion rules as for relational operators apply. If both
+strings and numbers are passed to `min()`, then any string values will be
+effectively ignored since both `1 < "abc"` and `1 > "abc"` comparisons
+yield false results.
+
+```javascript
+max(5, 2.1, 3, "abc", 0.3); // 5
+max(1, "abc"); // 1 (!)
+max("1", "abc"); // "abc"
+max("def", "abc", "ghi"); // "ghi"
+max(true, false); // true
+```