JavaScript math floor() method

The JavaScript math floor() method is used to get the largest integer value, either lower than or equal to a number.
Syntax:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Math.floor(n)
Math.floor(n)
Math.floor(n)

Parameters
n: It represents the number.

Returns
The largest integer value will be either lower than or equal to the specified number.

Example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
document.writeln(Math.floor(2.7));
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> document.writeln(Math.floor(2.7)); </script> </body> </html>
<!DOCTYPE html>
<html>
<body>
<script>
document.writeln(Math.floor(2.7));
</script>
</body>
</html>