1// For large data, it's better to use reduce. Supose arr has a large data in this case:
2const arr = [1, 5, 3, 5, 2];
3const max = arr.reduce((a, b) => { return Math.max(a, b) });
4
5// For arrays with relatively few elements you can use apply:
6const max = Math.max.apply(null, arr);
7
8// or spread operator:
9const max = Math.max(...arr);
10
1var values = [3, 5, 6, 1, 4];
2
3var max_value = Math.max(...values); //6
4var min_value = Math.min(...values); //1
1var nums = [1, 2, 3]
2Math.min.apply(Math, nums) // 1
3Math.max.apply(Math, nums) // 3
4Math.min.apply(null, nums) // 1
5Math.max.apply(null, nums) // 3