The parseInt() function can be used in javascript to remove numbers after the decimal point. The syntax format is "parseInt (floating point number)". The parseInt() function will skip any number of leading spaces when parsing, parse as many numeric characters as possible, and return NaN if the first non-space character is a non-numeric character.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
javascript removes the numbers after the decimal point
<script type="text/javascript"> var num=3234.14; var num2=parseInt(num); console.log(num2); </script>
Output:
Related function description:
The parseInt() function parses a string and returns an integer.
The parseInt() function is a global function, does not belong to any class method, and only parses integers. If the string prefix is "0x" or "0X", parseInt() interprets it as a hexadecimal number. It skips any number of leading spaces, parses as many numeric characters as possible, ignores what follows, and returns NaN if the first non-space character is a non-numeric character.
For example:
[Related recommendations: javascript learning tutorial]
The above is the detailed content of How to remove numbers after decimal point in javascript. For more information, please follow other related articles on the PHP Chinese website!