Math.ceil() - JavaScript | MDN - Mozilla

  • Skip to main content
  • Skip to search
Math.ceil() Baseline Widely available

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: -7

Syntax

jsMath.ceil(x)

Parameters

x

A 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); // Infinity

Specifications

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 contribute

This page was last modified on ⁨Jul 10, 2025⁩ by MDN contributors.

View this page on GitHub • Report a problem with this content Filter sidebar
  1. Standard built-in objects
  2. Math
  3. Static methods
    1. abs()
    2. acos()
    3. acosh()
    4. asin()
    5. asinh()
    6. atan()
    7. atan2()
    8. atanh()
    9. cbrt()
    10. ceil()
    11. clz32()
    12. cos()
    13. cosh()
    14. exp()
    15. expm1()
    16. f16round()
    17. floor()
    18. fround()
    19. hypot()
    20. imul()
    21. log()
    22. log1p()
    23. log2()
    24. log10()
    25. max()
    26. min()
    27. pow()
    28. random()
    29. round()
    30. sign()
    31. sin()
    32. sinh()
    33. sqrt()
    34. sumPrecise()
    35. tan()
    36. tanh()
    37. trunc()
  4. Static properties
    1. E
    2. LN2
    3. LN10
    4. LOG2E
    5. LOG10E
    6. PI
    7. SQRT1_2
    8. SQRT2

Từ khóa » Hàm Làm Tròn Trong Js