Converting Strings to Number
parseInt( string , radix )
The parseInt() function parses a string and returns an integer. The first argument is the value to parse and the second argument base, if present, specifies the base (radix) of the number whose string representation is contained in the string. The base argument can be any integer from 2 to 36.
If you pass more than one string, then only the first number in the string is returned.
Leading and trailing spaces are allowed while the parsing the string.
If you pass a string and it is not a number format, it will return NaN.
If you enter a floating format string , it will return the first integer part only.
If you enter a comma separated string , then the first number only parse and returned.
The second parameter base, if present, specifies the base (radix) of the number whose string representation is contained in the string. An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the above mentioned string. The default 10 for the decimal numeral system commonly used by humans. Always specify this parameter (10) to eliminate reader confusion and to guarantee predictable behavior.
radix 10 - default
The above code will return 56.
That is : 5*10 + 6 = 56
The above code will return 46.
That is : 5*8 + 6 = 46
The above code will return 86.
That is : 5*16 + 6 = 86
Note: parseInt is occasionally used as a means of turning a floating point number into an integer.
The above code will return 100.