CodesJava

Easy learning with example program codes

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 have to be get.

Returns
Integer part of a number.

Example

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

Output

18
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status