What is the JavaScript minimum function?

青灯夜游
Release: 2023-01-07 11:46:33
Original
2727 people have browsed it

The minimum value function in JavaScript is: the min() function of the Math object; use this method to return the number with the minimum value in the specified number list, the syntax "Math.min(n1,n2,n3 ,...,nX)”.

What is the JavaScript minimum function?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

In JavaScript, if you want to ask for the minimum value, you can use Math.min().

Give a chestnut:

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));
Copy after login

Look at the output:

What is the JavaScript minimum function?

Description:

Math object The min() method returns the number with the smallest value among the specified numbers.

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

Return value: the smallest value among the parameters. If there are no parameters, Infinity is returned. If an argument is NaN, or a non-numeric value that cannot be converted to a number, NaN is returned.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of What is the JavaScript minimum function?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template