Standard built-ins

Math.floor()

Try the free JavaScript compiler

Largest integer not greater than the input; rounds toward negative infinity. Converts x to Number; BigInt conversion throws TypeError.

Formal Syntax & Structure

javascript syntaxjavascript
Math.floor(x)

Parameters & Attributes

NameTypeDescription
xnumberNumber input or value coercible to Number.

Return Value

number

Result of the numerical operation, possibly NaN.

Working Example

Example Snippetjavascript
console.log(Math.floor(-2.1));
JavaScript Reference