javascript max() method


  Translation results:

UK [mæks] US [mæks]

adv.At most

javascript max() methodsyntax

Function: Returns the number with the larger value among the two specified numbers.

Syntax: Math.max(x...)

Parameters: x 0 or more values. Prior to ECMASCript v3, this method had only two parameters.

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

javascript max() methodexample

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script type="text/javascript">
//使用 max() 来返回指定数字中带有最高值的数字
    document.write(Math.max(5,7) + "<br />")
    document.write(Math.max(-3,5) + "<br />")
    document.write(Math.max(-3,-5) + "<br />")
    document.write(Math.max(7.25,7.30))

</script>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A