JavaScript Math.floor() Method

You are Here:

JavaScript Math.floor() Method

The Math.floor() method returns a number representing the nearest integer which is less than or equal to the specified number.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var result = Math.floor(4.8); document.write(result); </script> </body> </html>

Syntax

Math.floor(x)

Parameter Values

ValueTypeExplanation
xRequiredSpecifies a number.

Return Value

ValueExplanation
NumberReturns a number representing the nearest integer which is less than or equal to the specified number.
0If null is passed as a value, i.e, Math.floor(null).

More Examples

Example

HTML Online Editor
Math.floor(null); // 0 Math.floor(-4.2); // -5 Math.floor(-4.6); // -5 Math.floor(-4); // -4 Math.floor(4); // 4 Math.floor(4.2); // 4 Math.floor(4.6); // 4

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author