Math.floor()

ES1+

Returns the largest integer less than or equal to a given number.

Syntax

Math.floor(x)

Parameters

x number

A number

Return Value

number

The largest integer less than or equal to the given number

Examples

JavaScript
console.log(Math.floor(4.7));
console.log(Math.floor(4.2));
console.log(Math.floor(-4.7));
Output:
// 4 4 -5

Related Methods