English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Math.floor() Method

 JavaScript Math Object

TheMath.floor()The method returns the largest integer less than or equal to the given floating-point number.

If the passed parameter is an integer, the value will remain unchanged.

Since floor() is a static method of Math, you always use it asMath.floor(), rather than as a method of the Math object created.

Syntax:

Math.floor(x)
Math.floor(3.14);   // 3
Math.floor(.)95);// 0
Math.floor(5);  // 5
Math.floor(-18);// -18
Math.floor(-0.72);  // -1
Test and See‹/›

Browser Compatibility

All browsers fully support the Math.floor() method:

Method
Math.floor()YesYesYesYesYes

Parameter Value

ParameterDescription
xValue

Technical Details

Return Value:The largest integer less than or equal to the specified number
JavaScript Version:ECMAScript 1

 JavaScript Math Object