Standard built-ins

Math.round()

Try the free JavaScript compiler

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

NameTypeDescription
xnumberNumber 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));
JavaScript Reference