Javascript Reference - JavaScript floor() Method








The floor() method rounds a number down to the nearest integer, and returns the result.

Browser Support

floor() Yes Yes Yes Yes Yes

Syntax

Math.floor(x);

Parameter Values

Parameter Description
x Required. The number to round




Return Value

A Number representing the nearest integer when rounding downwards.

Example

The Math.floor() method is the floor function. Math.floor() rounds numbers down to the nearest integer value.


console.log(Math.floor(25.9)); //25 
console.log(Math.floor(25.5)); //25 
console.log(Math.floor(25.1)); //25 

The code above generates the following result.