🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_VALUE
Number.MAX_VALUE - JavaScript - MDN Web Docs
October 22, 2025 - The Number.MAX_VALUE static data property represents the maximum numeric value representable in JavaScript.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript - MDN Web Docs
The Math.max() static method returns the largest of the numbers given as input parameters, or -Infinity if there are no parameters.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.math.max
Math.Max Method (System) | Microsoft Learn
open System let print typ a b m = printfn $"{typ}: The greater of {a,3} and {b,3} is {m}." let xByte1, xByte2 = 1uy, 51uy let xShort1, xShort2 = -2s, 52s let xInt1, xInt2 = -3, 53 let xLong1, xLong2 = -4L, 54L let xSingle1, xSingle2 = 5f, 55f let xDouble1, xDouble2 = 6., 56. let xDecimal1, xDecimal2 = 7m, 57m // The following types are not CLS-compliant. let xSbyte1, xSbyte2 = 101y, 111y let xUshort1, xUshort2 = 102us, 112us let xUint1, xUint2 = 103u, 113u let xUlong1, xUlong2 = 104uL, 114uL printfn "Display the greater of two values:\n" print "Byte " xByte1 xByte2 (Math.Max(xByte1, xByte2)) p
🌐
TechOnTheNet
techonthenet.com › js › math_max.php
JavaScript: Math max() function
The max() function returns the largest value from the numbers provided. If no parameters are provided, the max() function will return -Infinity. If any of the parameters provided are not numbers, the max() function will return NaN. Math is a placeholder object that contains mathematical functions ...
🌐
W3Schools
w3schools.com › java › ref_math_max.asp
Java Math max() Method
Get the highest value from different ....println(Math.max(96L, 2048L)); Try it Yourself » · The max() method returns the number with the highest value from a pair of numbers....
🌐
TutorialsPoint
tutorialspoint.com › javascript › math_max.htm
JavaScript Math.max() Method
The Math.max() method in JavaScript accepts a set of arguments as parameters, finds the highest numeric value among it, and returns it. If no arguments are provided, -Infinity is returned, indicating that there is no maximum value.
🌐
Programiz
programiz.com › javascript › library › math › max
JavaScript Math max()
The max() method finds the maximum value among the specified values and returns it. let numbers = Math.max(12, 4, 5, 9, 0, -3); console.log(numbers); // Output: 12
🌐
W3Schools
w3schools.com › jsref › jsref_max_value.asp
JavaScript MAX_VALUE Property
Number.MAX_VALUE returns the largest number possible in JavaScript.
Top answer
1 of 7
15

Here is the Math.max code in Chrome V8 engine.

function MathMax(arg1, arg2) {  // length == 2
  var length = %_ArgumentsLength();
  if (length == 2) {
    arg1 = TO_NUMBER(arg1);
    arg2 = TO_NUMBER(arg2);
    if (arg2 > arg1) return arg2;
    if (arg1 > arg2) return arg1;
    if (arg1 == arg2) {
      // Make sure -0 is considered less than +0.
      return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg2 : arg1;
    }
    // All comparisons failed, one of the arguments must be NaN.
    return NaN;
  }
  var r = -INFINITY;
  for (var i = 0; i < length; i++) {
    var n = %_Arguments(i);
    n = TO_NUMBER(n);
    // Make sure +0 is considered greater than -0.
    if (NUMBER_IS_NAN(n) || n > r || (r === 0 && n === 0 && %_IsMinusZero(r))) {
      r = n;
    }
  }
  return r;
}

Here is the repository.

2 of 7
7

Below is how to implement the functions if Math.min() and Math.max() did not exist.

Functions have an arguments object, which you can iterate through to get its values.

It's important to note that Math.min() with no arguments returns Infinity, and Math.max() with no arguments returns -Infinity.

function min() {
  var result= Infinity;
  for(var i in arguments) {
    if(arguments[i] < result) {
      result = arguments[i];
    }
  }
  return result;
}

function max() {
  var result= -Infinity;
  for(var i in arguments) {
    if(arguments[i] > result) {
      result = arguments[i];
    }
  }
  return result;
}

//Tests
console.log(min(5,3,-2,4,14));       //-2
console.log(Math.min(5,3,-2,4,14));  //-2

console.log(max(5,3,-2,4,14));       //14
console.log(Math.max(5,3,-2,4,14));  //14

console.log(min());                  //Infinity
console.log(Math.min());             //Infinity

console.log(max());                  //-Infinity
console.log(Math.max());             //-Infinity

Find elsewhere
🌐
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
The Math.max() method returns the number with the highest value.
🌐
Educative
educative.io › answers › what-is-integermaxvalue
What is Integer.MAX_VALUE?
Integer.MAX_VALUE represents the maximum positive integer value that can be represented in 32 bits (i.e., 2147483647).
🌐
Math.js
mathjs.org › docs › reference › functions › max.html
Function max
Compute the maximum value of a matrix or a list with values. In case of a multidimensional array, the maximum of the flattened array will be calculated. When dim is provided, the maximum over the selected dimension will be calculated. Parameter dim is zero-based. math.max(a, b, c, ...) math.max(A) math.max(A, dimension)
🌐
Tutorialspoint
tutorialspoint.com › java › lang › math_max_int.htm
Java - Math max(int x, int y) Method
The java.lang.Math.max(int a, int b) returns the greater of two int values. That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value.
🌐
Inductive Automation
docs.inductiveautomation.com › appendix › system functions › system.math › max
system.math.max - Ignition User Manual - Inductive Automation
September 24, 2024 - Given a sequence of values, returns the greatest value in the sequence, also known as the "max" value. Returns NaN (Not a Number) if passed an empty sequence. This scripting function has no Client Permission restrictions. system.math.max(values) Float - The maximum value contained in the values ...
🌐
Programiz
programiz.com › java-programming › library › math › max
Java Math max()
In the above example, we have used the Math.max() method with int, long, float, and double type arguments. class Main { public static void main(String[] args) { // create an array of int type int[] arr = {4, 2, 5, 3, 6}; // assign first element of array as maximum value int max = arr[0]; for (int i = 1; i < arr.length; i++) {
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Math › max
JavaScript Math max() - Find Maximum Value | Vultr Docs
November 27, 2024 - This code evaluates the given numbers and outputs the highest value, which is 20. Use the spread operator to pass an array of numbers to Math.max().
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › Math › max
Java Math max() - Find Maximum Value | Vultr Docs
December 3, 2024 - The Math.max() function in Java offers a straightforward way to find the maximum value between two numbers. Ideal for applications across a broad spectrum of domains, this method enhances code efficiency and readability by abstracting away the need for manual comparisons.
🌐
Wolfram MathWorld
mathworld.wolfram.com › Maximum.html
Maximum -- from Wolfram MathWorld
November 23, 2008 - The largest value of a set, function, etc. The maximum value of a set of elements is denoted or , and is equal to the last element of a sorted (i.e., ordered) version of . For example, given the set , the sorted version is , so the maximum is 5.