JavaScript (ES2026) reference · Math Methods and Constants

JavaScript Math.floor() Method

Round a number down to the integer below it: Math.floor(4.9) is 4 and Math.floor(-4.1) is -5.

JavaScript (ES2026) Since ES1

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Math.floor(x)

Parameters

ParameterDescription
x A number.

Return value

An integer.

Examples

Round downTry it yourself
console.log(Math.floor(4.9), Math.floor(-4.1));

Output

4 -5
Format a durationTry it yourself
const seconds = 3725;
console.log(`${Math.floor(seconds / 3600)}h ${Math.floor((seconds % 3600) / 60)}m ${seconds % 60}s`);

Output

1h 2m 5s

Version history

VersionChange
JavaScript ES1Added

Was this page helpful?