, , reduce , . 4.
. : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce#Description
:
accumulator
currentValue
currentIndex
array (a reference to the array itself)
- , , reduce. Math.max , NaN.
EDIT: apply !
let values = [4,5,6,77,8,12,0,9];
let max = Math.max.apply(null, values);
let maxAnotherWay = Math.max(...values);
, Lodash, _.ary , :
let values = [4,5,6,77,8,12,0,9];
let max = values.reduce(_.ary(Math.max, 2),0);