What is Math.ceil() in JavaScript?
Math is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains the ceil() function, which is used to compute the smallest integer greater than or equal to a specified number.
Syntax
Math.ceil(param);
Parameter
param: This is the input value of theNumbertype for which we want to find theceil().
Numberin JavaScript is a 64-bit double-precision value which is the same asdoublein C# or Java.
Return value
Number: This rounds the input number and returns the next smallest integer greater than or equal to the input parameterparam. It is of theNumbertype.
Example
console.log("ceil(-1) = " + Math.ceil(-1));console.log("ceil(1) = " + Math.ceil(1));console.log("ceil(-10.54) = " + Math.ceil(-10.54));console.log("ceil(10.54) = " + Math.ceil(10.54));console.log("ceil(11.34) = " + Math.ceil(11.34));console.log("ceil(-0.5) = " + Math.ceil(-0.5));