- The parseInt() function parses a string and returns an integer.
- The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.
- Only the first number in the string is returned.
- If the first character cannot be converted to a number, parseInt() returns NaN.
Code:-
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>parseInt()</h1>
- <h2>77.36</h2>
- <input type="button" onclick="con_int();" value="parseInt(77.3)">
- <script>
- function con_int()
- {
- var n1 = "77.36";
- alert("Integer : " + parseInt(n1));
- }
- </script>
- </body>
- </html>
How to use The parselnt in JavaScript:- Geniusofstudent
Reviewed by Network security
on
July 02, 2019
Rating:
No comments: