JavaScript trunc() Method

Definition and Usage

trunc() The method returns the integer part of the number.

Note:This method does not round the number up or down to the nearest integer, it simply removes the decimal part.

Example

Returns the integer part of a number:

Math.trunc(8.76);

Try It Yourself

Syntax

Math.trunc(x)

Parameter Value

Parameter Description
x Required. Number.

Technical Details

Return Value: Numbers.
JavaScript Version: ECMAScript 6

Browser Support

Method Chrome Edge Firefox Safari Opera
trunc() 38 12 25 8 25

Related Pages

Tutorial:JavaScript Mathematics