JavaScript (ES2026) reference · Math Methods and Constants
JavaScript Math.ceil() Method
Round a number up to the next integer: Math.ceil(4.1) is 5 and Math.ceil(-4.1) is -4.
JavaScript (ES2026) Since ES1
Syntax
Math.ceil(x)
Parameters
| Parameter | Description |
|---|---|
x |
A number. |
Return value
An integer.
Examples
console.log(Math.ceil(4.1), Math.ceil(4), Math.ceil(-4.1));
Output
5 4 -4
const items = 47, perPage = 10;
console.log("pages:", Math.ceil(items / perPage));
Output
pages: 5
Version history
| Version | Change |
|---|---|
| JavaScript ES1 | Added |
Related
Math.floor()· Round a number down to the integer below it: Math.floor(4.9) is 4 and Math.floor(-4.1) is -5.Math.round()· Round a number to the nearest integer; halves round up towards +Infinity, so Math.round(-2.5) is -2.Math.trunc()· Remove the fractional part of a number, rounding towards zero: Math.trunc(-4.7) is -4.- JavaScript Math · tutorial
- JavaScript Numbers · tutorial