What is a min in javascript?

The Number.MIN_VALUE property represents the smallest positive numeric value representable in JavaScript.

Try it

Description

Number.MIN_VALUE is the smallest positive number (not the most negative number) that can be represented within float precision — in other words, the number closest to 0. The ECMAScript spec doesn't define a precise value that implementations are required to support — instead the spec says, "must be the smallest non-zero positive value that can actually be represented by the implementation". This is because small IEEE-754 floating point numbers are denormalized, but implementations are not required to support this representation, in which case Number.MIN_VALUE may be larger.

In practice, its precise value in mainstream engines like V8 (used by Chrome, Edge, Node.js), SpiderMonkey (used by Firefox), and JavaScriptCore (used by Safari) is 2-1074, or 5E-324.

Because MIN_VALUE is a static property of Number, you always use it as Number.MIN_VALUE, rather than as a property of a number value.

Examples

Using MIN_VALUE

The following code divides two numeric values. If the result is greater than or equal to MIN_VALUE, the func1 function is called; otherwise, the func2 function is called.

if (num1 / num2 >= Number.MIN_VALUE) {
  func1();
} else {
  func2();
}

Specifications

Specification
ECMAScript Language Specification
# sec-number.min_value

Browser compatibility

BCD tables only load in the browser

See also

More Examples

let a = Math.min(5, 10);
let b = Math.min(0, 150, 30, 20, 38);
let c = Math.min(-5, 10);
let d = Math.min(-5, -10);
let e = Math.min(1.5, 2.5);

Try it Yourself »


Definition and Usage

The Math.min() method returns the number with the lowest value.



Syntax

Parameters

Parameter Description
n1, n2,... Optional.
One or more numbers to compare.

Return Value

Type Description
Number The lowest number of the arguments.
-Infinity if no arguments are given.
NaN if one of the arguments is not a number.


Browser Support

Math.min() is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome IE Edge Firefox Safari Opera
Yes Yes Yes Yes Yes Yes



Definition and Usage

Number.MIN_VALUE returns the smallest number possible in JavaScript.

Number.MIN_VALUE has a value of 5e-324.

Note

MIN_VALUE is the value closest to 0.

Numbers smaller than this are converted to 0.

The most negative number is the negative MAX_NUMBER.


Number.MIN_VALUE

MIN_VALUE is a property of the JavaScript Number object.

You can only use it as Number.MIN_VALUE.

Using x.MIN_VALUE, where x is a variable, will return undefined:


Syntax

Return Value

Type Description
A number 5e-324

Browser Support

Number.MIN_VALUE is an ECMAScript1 (ES1) feature.

ES1 (JavaScript 1997) is fully supported in all browsers:

Chrome IE Edge Firefox Safari Opera
Yes Yes Yes Yes Yes Yes


What is a min in javascript?


This JavaScript tutorial explains how to use the math function called min() with syntax and examples.

Description

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.

Syntax

In JavaScript, the syntax for the min() function is:

Math.min([number1, number2, ... number_n]);

Parameters or Arguments

number1, number2, ... number_nOptional. The numbers that will be evaluated to determine the smallest value.

Returns

The min() function returns the smallest value from the numbers provided.

If no parameters are provided, the min() function will return Infinity.

If any of the parameters provided are not numbers, the min() function will return NaN.

Note

  • Math is a placeholder object that contains mathematical functions and constants of which min() is one of these functions.

Example

Let's take a look at an example of how to use the min() function in JavaScript.

For example:

console.log(Math.min(5, 10));
console.log(Math.min(60, 40, 20));
console.log(Math.min(-3, -6, -9, -12));

In this example, we have invoked the min() function using the Math class.

We have written the output of the min() function to the web browser console log, for demonstration purposes, to show what the min() function returns.

The following will be output to the web browser console log:

5
20
-12

In this example, the first output to the console log returned 5 which is the smallest of the values 5 and 10.

The second output to the console log returned 20 which is the smallest of the values 60, 40 and 20.

The third output to the console log returned -12 which is the smallest of the values -3, -6, -9 and -12.

Using the min() function to find the Largest Value in an Array

Finally, we'll take a look at how to use the min() function to find the smallest value in an array.

For example:

var totn_array = [2, 4, 6, 8, 10];

console.log(Math.min(...totn_array));

The following will be output to the web browser console log:

2

In this example, the min() method returned 2 which is the smallest value from the array called totn_array. This array consisted of 5 elements with the numeric values: 2, 4, 6, 8 and 10.

What is min and max JavaScript?

max() function returns the largest of zero or more numbers. and min function of Math object. The Math. min() function returns the smallest of zero or more numbers.

What does min mean in coding?

The min() function returns the item with the lowest value, or the item with the lowest value in an iterable. If the values are strings, an alphabetically comparison is done.

How is min defined in Java?

min() function is an inbuilt function in java that returns the minimum of two numbers. The arguments are taken in int, double, float and long. If a negative and a positive number is passed as an argument then the negative result is generated.

Why is Infinity min in Math?

min() method, it will return Infinity . When we pass a single argument to the Math. min() method, the argument is compared with infinity and the passed value is returned. This is because when we compare any number to infinity, infinity will always be the higher value; so, the number becomes the min value.