JavaScript Math trunc() methodThe JavaScript math trunc() method removes the fractional part of the given number and returns the remaining integer part only. SyntaxThe trunc() method is represented by the following syntax: Parameternum - A number. ReturnThe integer part of the given number. JavaScript Math trunc() method exampleHere, we will understand trunc() method through various examples. Example 1Let's see an example to print integer part of the given numbers. Test it NowOutput: 12 0 Example 2In this example, we will use trunc() method with negative numbers. Test it NowOutput: -12 0 Example 3Here, you can test trunc() method with your own test cases. Test it Now
Next TopicJavaScript Math
|
Javatpoint provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India