JavaScript Math.floor()
Examples
let x = Math.floor(1.6);
Try it Yourself »
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 »
Description
The Math.floor()
method rounds a number DOWN to the nearest integer.
JavaScript Rounding Functions
The Math.abs() MethodThe Math.ceil() Method
The Math.floor() Method
The Math.round() Method
The Math.fround() Method
The Math.trunc() Method
Syntax
Math.floor(x)
Parameters
Parameter | Description |
x | Required. A number. |
Return Value
Type | Description |
Number | The nearest integer to the number, rounding DOWN. |
Browser Support
Math.floor()
is an ECMAScript1 (JavaScriopt 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |