Convert one value to int with different radix in JavaScript
Description
The following code shows how to convert one value to int with different radix.
Example
<!--from ww w . j a v a 2 s .com-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
document.writeln(parseInt("10", 2)); //2 - parsed as binary
document.writeln(parseInt("10", 8)); //8 - parsed as octal
document.writeln(parseInt("10", 10));//10 - parsed as decimal
document.writeln(parseInt("10", 16));//16 - parsed as hexadecimal
</script>
</head>
<body>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Number parseInt
Convert "123asdf" to integer with parseInt(...
Convert "asdf123" to integer with parseInt(...
Convert empty string("") to integer with pa...
Covert value to int with radix in JavaScrip...
Covert value without 0x to int with radix 1...
Use parseInt() to convert float point value...
Use parseInt() to convert hexadecimal forma...
Use parseInt() to convert octal format valu...
Convert "123asdf" to integer with parseInt(...
Convert "asdf123" to integer with parseInt(...
Convert empty string("") to integer with pa...
Convert one value to int with different rad...
Convert string to create an integer value w...Covert value to int with radix in JavaScrip...
Covert value without 0x to int with radix 1...
Use parseInt() to convert float point value...
Use parseInt() to convert hexadecimal forma...
Use parseInt() to convert octal format valu...