JavaScript Math.floor()
Definition and Usage
The Math.floor() method rounds a number DOWNWARDS to the nearest integer, and returns the result.
More Examples
let a = Math.floor(0.60);
let b = Math.floor(0.40);
let c = Math.floor(5);
let d = Math.floor(5.1);
let e = Math.floor(-5.1);
let f = Math.floor(-5.9);
Try it Yourself »
Browser Support
Math.floor()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
Syntax
Math.floor(x)
Parameters
Parameter | Description |
---|---|
x | Required. The number to round. |
Return Value
A number representing the nearest integer when rounding downwards. |