ฟังก์ชัน ceil() ของอ็อบเจกต์ Math ยอมรับตัวเลขทศนิยมและส่งกลับจำนวนเต็มที่ใกล้เคียงที่สุดที่มากกว่าหรือเท่ากับจำนวนที่กำหนด หากตัวเลขที่ระบุเป็นจำนวนเต็ม ฟังก์ชันนี้จะคืนค่าเดิม
ไวยากรณ์
ไวยากรณ์ของมันคือดังต่อไปนี้
Math.ceil(169.36)
ตัวอย่าง
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result = Math.ceil(169.36);
document.write("ceil value of the of the given number: "+result);
</script>
</body>
</html> ผลลัพธ์
ceil value of the of the given number: 170