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

adv.至多

javascript max() 方法 語法

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

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

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

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

javascript max() 方法 範(fàn)例

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

<script type="text/javascript">
//使用 max() 來返回指定數(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>

執(zhí)行實(shí)例 ?

點(diǎn)擊 "執(zhí)行實(shí)例" 按鈕查看線上實(shí)例