<script>
document.write(parseInt(15,16)) // Output 21, Hexadecimal Number system
document.write("<br>");
document.write(parseInt(15,8)) // Output 13, Octal Number system
document.write("<br>");
document.write(parseInt(5,2)) // Output NaN, Not a Binary Number system
document.write("<br>");
document.write(parseInt(101,2)) // Output 5, Binary Number system
document.write("<br>");
</script>
By using parseInt function we can convert strings to integer.
Without any value for Radix or if Radix = 0 then if input string starts with 0x or 0X then radix is considered as 16 ( hexadecimal number system )
Similarly if input string starts with 0 then radix is considered as 8 ( Octal number system )
In all other cases ( input string starting with any other value ) Radix is assumed as 10 ( decimal system ).
<script>
document.write(parseInt(0XA)) // Output 10 , Hexadecimal Number system
document.write("<br>");
document.write(parseInt(011)) // Output 9 , Octal Number system
document.write("<br>");
</script>
It is always better to specify Radix ( even for decimal number system )