Standard built-ins
Math.round()
Nearest integer with half ties toward positive infinity. May produce negative zero for values near zero. Converts x to Number; BigInt conversion throws TypeError.
Formal Syntax & Structure
javascript syntaxjavascript
Math.round(x)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | number | Number input or value coercible to Number. |
Return Value
number
Result of the numerical operation, possibly NaN.
Working Example
Example Snippetjavascript
console.log(Math.round(-2.5),Math.round(2.5));