JS Math.max () function

Source: Internet
Author: User

Math.max (A, b,..., x, y)--Returns the larger value in several numbers
Max is the abbreviation of maximum, the meaning of Chinese "maximum quantity"

max function Syntax
math.max (A, b,..., x, y);


max function parameter
a,b,..., x, y-numbers of type number, which can be decimals, integers, positive, negative, 0.


max function return value
Returns the larger value of a number of values

Note: If the Max function does not give any arguments, return-infinity

document.write (Math.max (5,8,6,-5,-6));
document.write (Math.max ());
document.write (Math.max ("Dreamdu", 8));
document.write (Math.max (nan,0));
result:

8
-infinity
nan
nan

 

----------------------------------------------------- -----------------------------

math Other related functions:
math.random ()
Returns a random number between 0 and 1.


math.round ()
rounded rounding.


math.ceil ()
return value: Returns the integer that is greater than or equal to X and is closest to.
note: If X is a positive number, the decimal is "in" and if X is a negative number, the decimal "is".


Math.floor ()
Return value: Returns the integer that is less than or equal to x and closest to.
Note: If X is a positive number, the decimal is "in" and if X is negative, the decimal is "in".

JS Math.max () function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.