Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to find the minimum value with javascript

Shulou Source: shulou.com Published: 2022-05-31 10:52:29 10月03日 Update

Today Xiaobian to share with you how to use javascript to find the minimum value of the relevant knowledge points, detailed content, clear logic, I believe that most people are still too familiar with this knowledge, so share this article for your reference, I hope you read this article after some harvest, let's take a look at it.

In javascript, the Min() method of the Math object can be used to find the minimum value, which can return the minimum value of zero or more values, syntax format "Math.min(value1, value2, value3,..., Value N) "; returns"NaN"if any parameter cannot be converted to a numeric value.

Operating environment of this tutorial: Windows 7 system, Javascript version 1.8.5, Dell G3 computer.

In javascript, the Min() method of the Math object can be used to find the minimum value.

Here's an example:

console.log(Math.min(5,10));console.log(Math.min(0,150,30,20,38));console.log(Math.min(-5,10));console.log(Math.min(-5,-10));console.log(Math.min(1.5,2.5));

Output:

Description:

Math.min() Returns the minimum of zero or more values.

syntax

Math.min(n1,n2,n3,..., nX)

Return value:

The smallest number of given values.

Description:

Since min is a static method of Math, it should be used like this: Math.min(), not as a method of the Math instance you create (Math is not a constructor).

If there are no arguments, the result is Infinity.

If any parameter cannot be converted to a numeric value, the result is NaN.

Above is "how to use javascript to find the minimum value" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Minimum numerical values methods knowledge articles parameters more content objects results syntax any different large functions most examples that is tutorials formats Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Tech Info OPPO Reno Linux Docker