-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-max.out
31 lines (26 loc) · 1.05 KB
/
test-max.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
max:
[1] -> 1
[5, 1, 2, 3, 4] -> 5
["a", "b", "c"] -> "c"
["20", "3"] -> "3"
["3", "20"] -> "3"
[20, 3] -> 20
[3, 20] -> 20
max of empty array is undefined:
[] -> undefined
[null] -> undefined
[undefined] -> undefined
[NaN] -> undefined
[NaN, NaN] -> undefined
max ignores null, undefined, and NaN:
[NaN, 1, 2, 3, 4, 5] -> 5
[1, 2, 3, 4, 5, NaN] -> 5
[10, null, 3, undefined, 3, NaN] -> 10
max compares heterogenous types as numbers:
[20, "3"] -> 20
["20", 3] -> "20"
[3, "20"] -> "20"
["3", 20] -> 20
max applies accessor function:
[1, 2, 3, 4, 5], [2, 4, 6, 8, 10] -> 2
[1, 2, 3, 4, 5] -> 4