Dùng Math.max(...values) trả về số lớn nhất. Nếu không truyền đối số, trả về -Infinity.
Cú pháp
Math.max(value1, value2, ... valueN)
Ví dụ
<html>
<head>
<title>Phương thức Math.max trong JavaScript</title>
</head>
<body>
<script>
document.write("max(24,220,-80,100) = " + Math.max(24, 220, -80, 100) + "<br>"); // 220
document.write("max(-10,-24,-98) = " + Math.max(-10, -24, -98) + "<br>"); // -10
document.write("max(0,-1) = " + Math.max(0, -1)); // 0
</script>
</body>
</html>