1
2//For Values
3var arr =[1,10,3]
4var min = Math.min.apply(null, arr),
5 max = Math.max.apply(null, arr);
6
7//For Objects
8var arr = [{a: 1},{a: 10},{a: 3}]
9var values = arr.map(val => val.a);
10var max = Math.max.apply(null, values);
11console.log(max)
12
1//get min/max value of arrays
2function getArrayMax(array){
3 return Math.max.apply(null, array);
4}
5function getArrayMin(array){
6 return Math.min.apply(null, array);
7}
8var ages=[11, 54, 32, 92];
9var maxAge=getArrayMax(ages); //92
10var minAge=getArrayMin(ages); //11
1//get min/max value of arrays
2function getArrayMax(array){
3 return Math.max.apply(null, array);