
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I remove the decimal part of JavaScript number?
To remove the decimal part from a number, use the JavaScript Math.trunc() method. The method returns the integer part of a number by removing the decimal part.
Example
<!DOCTYPE html> <html> <body> <p>Value:</p> <script> var myFloat = 4.5; var myTrunc = Math.trunc( myFloat ); document.write(myTrunc+ " "); </script> </body> </html>
Output
Value: 4
- Related Questions & Answers
- Retrieving the decimal part only of a number in JavaScript
- How can I round a number to 1 decimal place in JavaScript?
- Finding length of repeating decimal part in JavaScript
- How can I use MySQL INTERVAL keyword while extracting the part of the date?
- Reversing the bits of a decimal number and returning new decimal number in JavaScript
- How can I remove all child elements of a DOM node in JavaScript?
- Decimal count of a Number in JavaScript
- How can I remove a child node in HTML using JavaScript?
- How can I remove a specific item from an array JavaScript?
- How can I round down a number in JavaScript?
- How can I count the number of days in MySQL?
- How can I remove items out of a Python tuple?
- How to get the port number part of the href attribute of an area in JavaScript?
- How can I remove a specific item from an array in JavaScript
- How can we validate decimal numbers in JavaScript?
Advertisements