Easy Tutorial
❮ Prop Style Outlinewidth Prop Radio Checked ❯

JavaScript round() Method

JavaScript Math Object

Example

The round() method rounds a number to the nearest integer:

Output result:


Definition and Usage

The round() method rounds a number to the nearest integer.

Note: 2.49 will round to 2, and 2.5 will round to 3.


Browser Support

All major browsers support the round() method.


Syntax

Parameter Values

Parameter Description
x Required. Must be a number.

Return Value

Type Description
Number The nearest integer.

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

Rounding different numbers to the nearest integer:

a, b, c, d, e, and f output result:


JavaScript Math Object

❮ Prop Style Outlinewidth Prop Radio Checked ❯