Dùng Math.floor(x) làm tròn xuống đến số nguyên gần nhất.
Ví dụ
<html>
<head>
<title>Phương thức Math.floor trong JavaScript</title>
</head>
<body>
<script>
document.write("floor(50.3) = " + Math.floor(50.3) + "<br>"); // 50
document.write("floor(20.7) = " + Math.floor(20.7) + "<br>"); // 20
document.write("floor(-5.8) = " + Math.floor(-5.8) + "<br>"); // -6
document.write("floor(-3.1) = " + Math.floor(-3.1)); // -4
</script>
</body>
</html>