javascript maximum number code example

Example 1: javascript int max

console.log(Number.MAX_SAFE_INTEGER);
// expected output: 9007199254740991

Example 2: js maximum number value

Number.MAX_VALUE;

Example 3: 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 4: Find the maximum number of an array js

function getMaxOfArray(numArray) {
    return Math.max.apply(null, numArray);
}

Example 5: javascript max number

MAX_SAFE_INTEGER = 9007199254740991