Math max js code example
Example 1: javascript int max
console.log(Number.MAX_SAFE_INTEGER);
Example 2: Find the maximum number of an array js
var arr = [1, 2, 3];
var max = arr.reduce(function(a, b) {
return Math.max(a, b);
});
Example 3: js max value of array
let numbers = [4, 13, 27, 0, -5];
Math.max.apply(null, numbers);
Example 4: javascript max array
var values = [3, 5, 6, 1, 4];
var max_value = Math.max(...values);
var min_value = Math.min(...values);
Example 5: math.max in javascript
Math.max() function returns the largest of the zero or more numbers given as input parameters.
Math.max(1,10,100);
Example 6: javascript get array min and max
function getArrayMax(array){
return Math.max.apply(null, array);
}
function getArrayMin(array){
return Math.min.apply(null, array);
}
var ages=[11, 54, 32, 92];
var maxAge=getArrayMax(ages);
var minAge=getArrayMin(ages);