 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 do I convert a string into an integer in JavaScript?
The parseInt() method in JavaScript converts a string into a number. The method returns NaN if the value entered cannot be converted to a number.
Example
You can try to run the following code to convert a string into an integer −
<!DOCTYPE html> <html>    <body>       <button onclick = "display()">Check</button>       <p id = "demo"></p>       <script>          function display() {             var val1 = parseInt("50") + "<br>";             var val2 = parseInt("52.40") + "<br>";             var val3 = parseInt(" 75 ") + "<br>";             var res = val1 + val2 + val3;             document.getElementById("demo").innerHTML = res;          }       </script>    </body> </html>Advertisements
 