How TO - Remove Decimals of a Number


Learn how to remove the decimal part of a number in JavaScript.


Remove Decimals

You can use the Math.trunc() method to remove the decimals of a number:

Example

let x = Math.trunc(8.7512356); // 8
Try it Yourself »

Tip: Learn more about the Math.trunc() method in our JavaScript Reference.


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.