Math.ceil() - JavaScript | MDN - Mozilla
Có thể bạn quan tâm
- Skip to main content
- Skip to search
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
- Learn more
- See full compatibility
- Report feedback
The Math.ceil() static method always rounds up and returns the smallest integer greater than or equal to a given number.
In this article
- Try it
- Syntax
- Description
- Examples
- Specifications
- Browser compatibility
- See also
Try it
console.log(Math.ceil(0.95)); // Expected output: 1 console.log(Math.ceil(4)); // Expected output: 4 console.log(Math.ceil(7.004)); // Expected output: 8 console.log(Math.ceil(-7.004)); // Expected output: -7Syntax
jsMath.ceil(x)Parameters
xA number.
Return value
The smallest integer greater than or equal to x. It's the same value as -Math.floor(-x).
Description
Because ceil() is a static method of Math, you always use it as Math.ceil(), rather than as a method of a Math object you created (Math is not a constructor).
Examples
Using Math.ceil()
jsMath.ceil(-Infinity); // -Infinity Math.ceil(-7.004); // -7 Math.ceil(-4); // -4 Math.ceil(-0.95); // -0 Math.ceil(-0); // -0 Math.ceil(0); // 0 Math.ceil(0.95); // 1 Math.ceil(4); // 4 Math.ceil(7.004); // 8 Math.ceil(Infinity); // InfinitySpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification# sec-math.ceil |
Browser compatibility
See also
- Math.abs()
- Math.floor()
- Math.round()
- Math.sign()
- Math.trunc()
Help improve MDN
Was this page helpful to you? Yes No Learn how to contributeThis page was last modified on Jul 10, 2025 by MDN contributors.
View this page on GitHub • Report a problem with this content Filter sidebar- Standard built-in objects
- Math
- Static methods
- abs()
- acos()
- acosh()
- asin()
- asinh()
- atan()
- atan2()
- atanh()
- cbrt()
- ceil()
- clz32()
- cos()
- cosh()
- exp()
- expm1()
- f16round()
- floor()
- fround()
- hypot()
- imul()
- log()
- log1p()
- log2()
- log10()
- max()
- min()
- pow()
- random()
- round()
- sign()
- sin()
- sinh()
- sqrt()
- sumPrecise()
- tan()
- tanh()
- trunc()
- Static properties
- E
- LN2
- LN10
- LOG2E
- LOG10E
- PI
- SQRT1_2
- SQRT2
Từ khóa » Hàm Làm Tròn Trong Js
-
JavaScript: Phương Thức Làm Tròn Số ToFixed - Đại Phố Web & Hosting
-
Math Round() Trong JavaScript
-
Làm Tròn đến Tối đa 2 Chữ Số Thập Phân (chỉ Khi Cần Thiết)? - HelpEx
-
Hàm Math.round() Trong Javascript - Freetuts
-
Làm Tròn Số Nguyên Trong Javascript - Darkedeneurope
-
Math Round() Trong JavaScript - Hoclaptrinh
-
Javascript Cách Làm Tròn Số | Bang Andre
-
[Hướng Dẫn] Làm Tròn Số Trong Javascript đơn Giản Nhất [year
-
Làm Tròn Số Thập Phân Với Javascript - Gists · GitHub
-
Math.round() - JavaScript - MDN - Mozilla
-
Làm Thế Nào để Bạn Làm Tròn đến Số Nguyên Gần Nhất Trong ...
-
Lấy 2 Số Sau Dấu Phẩy Trong JavaScript
-
Hàm Math.round() Trong Javascript - Javascript Function
-
Sử Dụng Math Trong JavaScript - Viblo