Math.ceil
Returns the smallest integer greater than or equal to a given number (rounds up)
Syntax
Math.ceil(x)Parameters
| Parameter | Type | Description |
|---|---|---|
| x | number | A number |
Return Value
The smallest integer >= x
Examples
console.log(Math.ceil(1.1)); // 2
console.log(Math.ceil(-1.1)); // -1
console.log(Math.ceil(4)); // 4const pages = Math.ceil(95 / 10);
console.log(pages); // 10const prices = [9.99, 14.5, 3.01];
const rounded = prices.map(Math.ceil);
console.log(rounded); // [10, 15, 4]Understanding Math.ceil
The Math.ceil method in JavaScript returns the smallest integer greater than or equal to a given number (rounds up). It belongs to the Math object and is one of the most widely used methods for working with math values in modern JavaScript and TypeScript applications.
The method signature is Math.ceil(x). It accepts 1 parameter: x. When called, it returns the smallest integer >= x. Understanding when and how to use ceil() helps you write more expressive, readable code.
Common use cases for Math.ceil include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like math-floor, math-round, math-trunc, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Math.ceil is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
More Math Methods
Other methods in the Math object
Related Tools
More Math Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.