JavaScript Math floor() Method (original) (raw)

Last Updated : 07 Nov, 2024

The **Math.floor() method in **JavaScript is used to round off a number down to the nearest integer, moving towards the lower value. **This function is useful when you want to ensure that the result is always rounded down, regardless of whether the number is positive or negative.

**Syntax

Math.floor( value );

JavaScript `

console.log("Floor Value of 5.89 is: ", Math.floor(5.89)); console.log("Floor Value of 5.19 is: ", Math.floor(5.19));

`

Output

Floor Value of 5.89 is: 5 Floor Value of 5.19 is: 5

**Parameters: Math.floor() method accepts a single numeric argument.

**Return Value: The **Math.floor() method returns the smallest integer less than or equal to the given number.

**Example 1: Round off the negative number to smaller integer.

JavaScript `

console.log("Floor Value of -89.02 is: ", Math.floor(-89.02));

`

Output

Floor Value of -89.02 is: -90

**Note: The Math.floor() method does not work on integer value, it only works on float values.

We have a complete list of JavaScript Math methods, to check those please go through this JavaScript Math Object Complete reference article.

**Supported Browsers

Similar Reads