Skip to content

Commit 8bd340f

Browse files
committed
Math.max.apply note is confusing
1 parent bf6de67 commit 8bd340f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

chapters/arrays/max-array-value.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,14 @@ Math.max [12, 32, 11, 67, 1, 3]...
1616
# => 67
1717
{% endhighlight %}
1818

19-
Alternatively, it's possible to use ES5 `reduce` method. For backward compatibility with older JavaScript implementations, use Math.max.apply:
19+
Alternatively, it's possible to use ES5 `reduce` method. For backward compatibility with older JavaScript implementations, use the above.
2020

2121
{% highlight coffeescript %}
2222
# ECMAScript 5
2323
[12,32,11,67,1,3].reduce (a,b) -> Math.max a, b
2424
# => 67
25-
26-
# Pre-ES5
27-
Math.max.apply(null, [12,32,11,67,1,3])
28-
# => 67
2925
{% endhighlight %}
3026

3127
## Discussion
3228

33-
`Math.max` compares every argument and returns the largest number from arguments. The ellipsis (`...`) converts every array value into argument which is given to the function. You can also use it with other functions which take variable ammount of arguments, such as `console.log`.
29+
`Math.max` compares every argument and returns the largest number from arguments. The ellipsis (`...`) converts every array value into argument which is given to the function. You can also use it with other functions which take variable ammount of arguments, such as `console.log`.

0 commit comments

Comments
 (0)