ceil()
ceil(
n,precision):number
Computes number rounded up to precision.
DEPRECATED
Use Math.ceil() directly instead.
Parametersโ
n: numberโ
The number to round up.
precision: number = 0โ
The precision to round up to. Defaults to 0.
Returns: numberโ
The rounded up number.
See Alsoโ
Sinceโ
2.0.0
Also known asโ
ceil (Lodash, es-toolkit) ยท โ (Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)
Exampleโ
// โ Deprecated approach
ceil(4.006); // => 5
ceil(6.004, 2); // => 6.01
ceil(6040, -2); // => 6100
// โ
Recommended approach
Math.ceil(4.006); // => 5
Math.ceil(6.004 * 100) / 100; // => 6.01
Math.ceil(6040 / 100) * 100; // => 6100
How it works?โ
Rounds number up to specified precision.
Deprecated: Use Math.ceil() directly.
Native Equivalentโ
// โ ceil(value)
// โ
Math.ceil(value)
Use Casesโ
Round up ๐โ
Round number up to nearest integer.
Math.ceil(4.1); // 5
Math.ceil(-4.9); // -4
Calculate pagesโ
Calculate total pages needed.
const totalPages = Math.ceil(items.length / pageSize);