Math.floor()
Math.floor(x) → number
Returns the largest integer less than or equal to x.
Rounds x down to the previous integer. Integers are returned unchanged. For negative values this rounds away from zero; use Math.trunc() to round toward zero.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| x | number | optional | — | A number. |
Returns
number
The largest integer less than or equal to x.
Example
let f = Math.floor(4.8); // 4