JavaScript Math floor() Method

The Javascript Math.floor() method is used to round off the number passed as a parameter to its nearest integer in a Downward direction of rounding i.e. towards the lesser value.

Syntax: 

Math.floor(value)

Parameters: This method accepts a single parameter as mentioned above and described below: 

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

Below is an example of the Math floor() Method. 

Example 1: This example rounds off the value of the parameter to 0 .




<script type="text/javascript">
    console.log("Result : " + Math.floor(.89));
</script>

Output: 



Result : 0

Example 2: When a negative number is passed as a parameter. 




<script type="text/javascript">
         console.log("Result : " + Math.floor(-89.02));
</script>

Output: 

Result : -90

Example 3: When zero is passed as a parameter.




<script type="text/javascript">
         console.log("Result : " + Math.floor(0));
</script>

Output: 

Result : 0

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

Supported Browsers: 


Article Tags :