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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Math.ceil(x)

Parameters

ParameterDescription
x A number.

Return value

An integer.

Examples

Round upTry it yourself
console.log(Math.ceil(4.1), Math.ceil(4), Math.ceil(-4.1));

Output

5 4 -4
Number of pagesTry it yourself
const items = 47, perPage = 10;
console.log("pages:", Math.ceil(items / perPage));

Output

pages: 5

Version history

VersionChange
JavaScript ES1Added

Was this page helpful?