MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › min
Math.min() - JavaScript - MDN Web Docs
The Math.min() static method returns the smallest of the numbers given as input parameters, or Infinity if there are no parameters.
W3Schools
w3schools.com › jsref › jsref_min.asp
JavaScript Math min() Method
The Math.min() method returns the number with the lowest value.
Videos
Math.js
mathjs.org › docs › reference › functions › min.html
math.js
math.min(2, 1, 4, 3) // returns 1 math.min([2, 1, 4, 3]) // returns 1 // minimum over a specified dimension (zero-based) math.min([[2, 5], [4, 3], [1, 7]], 0) // returns [1, 3] math.min([[2, 5], [4, 3], [1, 7]], 1) // returns [2, 3, 1] math.max(2.7, 7.1, -4.5, 2.0, 4.1) // returns 7.1 math.min(2.7, 7.1, -4.5, 2.0, 4.1) // returns -4.5 ·
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › Math › min
Math.min() - JavaScript - UDN Web Docs: MDN Backup
The static function Math.min() returns the lowest-valued number passed into it, or NaN if any parameter isn't a number and can't be converted into one.
LaunchCode
education.launchcode.org › intro-to-professional-web-dev › appendices › math-method-examples › max-and-min-examples.html
Math.max and Math.min Examples — Introduction to Professional Web Development in JavaScript documentation
Math.min(x, y, z, ...) This method finds and returns the smallest value from a set of numbers (x, y, z,...). To find the minimum value in an array, see below. Example · console.log(Math.min(2, 3, 100.01, 0, -5.2, 100)); Console Output · -5.2 · Unfortunately, the max and min methods will ...
TechOnTheNet
techonthenet.com › js › math_min.php
JavaScript: Math min() function
In JavaScript, min() is a function that is used to return the smallest value from the numbers provided as parameters. Because the min() function is a static function of the Math object, it must be invoked through the placeholder object called Math.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript - MDN Web Docs
js · const arr = [1, 2, 3]; const max = Math.max(...arr); However, both spread (...) and apply will either fail or return the wrong result if the array has too many elements, because they try to pass the array elements as function parameters. See Using apply and built-in functions for more details. The reduce solution does not have this problem. Math.min() Was this page helpful to you?
TutorialsPoint
tutorialspoint.com › javascript › math_min.htm
JavaScript Math.min() Method
In JavaScript, the Math.min() method accepts any number of arguments, and it returns the minimum value among those arguments.If any of the arguments is not a number, "NaN" (Not-a-Number) is returned.
Scaler
scaler.com › home › topics › math min() javascript function
Math min() JavaScript Function - Scaler Topics
May 4, 2023 - The Math.min() function returns the smallest value of all the passed values. In case no value is passed to the function it will return positive infinity as it compares the first value with positive infinity and in absence of a first value, the ...
Programiz
programiz.com › javascript › library › math › min
JavaScript Math min()
The min() method finds the minimum value among the specified values and returns it. let numbers = Math.min(12, 4, 5, 9, 0, -3); console.log(numbers); // Output: -3
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
Educative
educative.io › answers › what-are-mathmin-and-mathmax-in-javascript
What are Math.min() and Math.max() in JavaScript?
Math.min() to find the minimum of n elements.
GitHub
github.com › mdn › content › blob › main › files › en-us › web › javascript › reference › global_objects › math › min › index.md
content/files/en-us/web/javascript/reference/global_objects/math/min/index.md at main · mdn/content
The **`Math.min()`** static method returns the smallest of the numbers given as input parameters, or {{jsxref("Infinity")}} if there are no parameters.
Author mdn
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MIN_VALUE
Number.MIN_VALUE - JavaScript - MDN Web Docs
July 10, 2025 - The Number.MIN_VALUE static data property represents the smallest positive numeric value representable in JavaScript.