JavaScript math trunc() method

The JavaScript math trunc() method is used to get the integer part of a number.
Syntax:

Math.trunc(n)

Parameters
n: It represents the number whose integer part has to be got.

Returns
The integer part of a number.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
document.writeln(Math.trunc(18.556));
</script>
</body>
</html>