THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript trunc() Method

❮ JavaScript Math Object

Example

Return the integer part of a number:

Math.trunc(8.76);
Try it Yourself »

Definition and Usage

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

Note: This method will NOT round the number up/down to the nearest ingeger, but simply remove the decimals.


Browser Support

Method
trunc() 38 12 25 8 25

Syntax

Math.trunc(x)

Parameter Values

Parameter Description
x Required. A number

Technical Details

Return Value: A Number
JavaScript Version: ECMAScript 6

❮ JavaScript Math Object