728x90
✨ 반올림이 필요할 때 사용하는 helper method
💻Example Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const num1 = Math.round( 5.9 ); | |
const num2 = Math.round( 5.5 ); | |
const num3 = Math.round( 5.1 ); | |
console.log(num1); | |
console.log(num2); | |
console.log(num3); |

🧨 반올림이 필요할 경우에 사용할 수 있다.
👉 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
Math.round()
The Math.round() function returns the value of a number rounded to the nearest integer.
developer.mozilla.org
'JavaScript > Built-in Method etc.' 카테고리의 다른 글
Set (Object) (0) | 2020.02.20 |
---|---|
String.prototype.localeCompare() (0) | 2020.02.20 |
Math.abs() (0) | 2020.01.28 |
Math.PI (0) | 2020.01.28 |
Array.prototype.forEach() (0) | 2020.01.23 |