Others



JavaScript Math.floor()


The Math.floor(x) method used to returns the rounded DOWN number to the nearest integer.

Syntax
Math.floor(x)

Here, floor() is a static method. Hence, we use it as Math.floor().

Parameters
  • x - (Required).A number.
Return Value
  • Number - The value of x rounding DOWN to the nearest integer.
Example
console.log(Math.floor(10.9));  //10
console.log(Math.floor(10.5));  //10
console.log(Math.floor(10.7));  //10
console.log(Math.floor(-10.1)); //-11
console.log(Math.floor(-10.9)); //-11
console.log(Math.floor(-10.7)); //-11
Try it Yourself

JavaScript Math Functions