
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Convert the string of any base to integer in JavaScript
The parseInt function available in JavaScript has the following signature −
parseInt(string, radix);
Where, the paramters are the following −
String − The value to parse. If this argument is not a string, then it is converted to one using the ToString method. Leading whitespace in this argument is ignored.
Radix − An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the string.
So we can pass the string and the radix and convert any numbner with base from 2 to 36 to integer using this method.
Example
console.log(parseInt("100", 10)) console.log(parseInt("10", 8)) console.log(parseInt("101", 2)) console.log(parseInt("2FF3", 16)) console.log(parseInt("ZZ", 36))
Output
100 8 5 12275 1295
- Related Articles
- How to convert a string of any base to an integer in JavaScript?
- Convert integer array to string array in JavaScript?
- How to convert a string into integer in JavaScript?
- How to convert String to Integer and Integer to String in Java?
- Convert Integer to Hex String in Java
- Convert string to integer/ float in Arduino
- How do I convert a string into an integer in JavaScript?
- C# Program to Convert Integer to String
- How to convert a string into an integer without using parseInt() function in JavaScript?
- Python – Convert Integer Matrix to String Matrix
- Program to convert List of Integer to List of String in Java
- Program to convert List of String to List of Integer in Java
- Program to convert Set of Integer to Set of String in Java
- Program to convert set of String to set of Integer in Java
- Haskell Program to convert the string into an integer

Advertisements