英 [m?ks]? ?美 [m?ks]??

adv.至多

javascript max()方法 語(yǔ)法

作用:返回兩個(gè)指定的數(shù)中帶有較大的值的那個(gè)數(shù)。

語(yǔ)法:Math.max(x...)

參數(shù):x ? ?0 或多個(gè)值。在 ECMASCript v3 之前,該方法只有兩個(gè)參數(shù)。? ??

返回:參數(shù)中最大的值。如果沒(méi)有參數(shù),則返回 -Infinity。如果有某個(gè)參數(shù)為 NaN,或是不能轉(zhuǎn)換成數(shù)字的非數(shù)字值,則返回 NaN。

javascript max()方法 示例

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

<script type="text/javascript">
//使用 max() 來(lái)返回指定數(shù)字中帶有最高值的數(shù)字
    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>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例