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 โจ2015๋ 7์โฉ.
Math.ceil()
์ ์ ๋ฉ์๋๋ ์ธ์ ๋ ์ฌ๋ฆผํ์ฌ ์ฃผ์ด์ง ์ซ์๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ์ ๊ฐ์ฅ ์์ ์ ์๋ฅผ ๋ฐํํฉ๋๋ค.
์๋ํด ๋ณด๊ธฐ
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
๊ตฌ๋ฌธ
js
Math.ceil(x)
๋งค๊ฐ๋ณ์
x
-
์ซ์
๋ฐํ ๊ฐ
x
๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ์ ๊ฐ์ฅ ์์ ์ ์๋ฅผ ๋ฐํํฉ๋๋ค. -Math.floor(-x)
์ ๋์ผํ ๊ฐ์
๋๋ค.
์ค๋ช
ceil()
์ Math
์ ์ ์ ๋ฉ์๋์ด๋ฏ๋ก, ์์ฑํ Math
๊ฐ์ฒด(Math
๋ ์์ฑ์๊ฐ ์๋๋๋ค)์ ๋ฉ์๋๋ก ์ฌ์ฉํ์ง ์๊ณ , ์ธ์ ๋ Math.ceil()
์ผ๋ก ์ฌ์ฉํ์ธ์.
์์
Math.ceil() ์ฌ์ฉํ๊ธฐ
js
Math.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
๋ช ์ธ์
Specification |
---|
ECMAScriptยฎ 2026 Language Specification # sec-math.ceil |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ