Convert string to create an integer value with parseInt(str) in JavaScript

Description

The following code shows how to convert string to create an integer value with parseInt(str).

Example


<!-- www . j ava 2s  .co  m-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
document.writeln(parseInt("1234asdf"));
</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Convert string to create an integer value with parseInt(str) in JavaScript
Home »
  Javascript Tutorial »
    Data Type »
      Number parseInt
Javascript Tutorial Number parseInt
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...