Search notes:

Javascript: parseInt

parseInt creates an integer from a String.
<!DOCTYPE html>
<html>
<head>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
  <title>parseInt</title>

  <script type="text/javascript">
    
    function main() {

      var out = document.getElementById('out');

      out.innerHTML  = parseInt('42xyz'        ) + '<br>'; // 42
      out.innerHTML += parseInt('   42xyz'     ) + '<br>'; // 42
      out.innerHTML += parseInt('abc42xyz'     ) + '<br>'; // NaN
      out.innerHTML += parseInt(' 100    '     ) + '<br>'; // 100
      out.innerHTML += parseInt('0100    '     ) + '<br>'; // 100
      out.innerHTML += parseInt('011     '     ) + '<br>'; // 100
      out.innerHTML += parseInt('0x100   '     ) + '<br>'; // 256
      out.innerHTML += parseInt('  100   ' , 16) + '<br>'; // 256
      out.innerHTML += parseInt('deadbeef'     ) + '<br>'; // NaN
      out.innerHTML += parseInt('deadbeef' , 16) + '<br>'; // 3735928559

    }

  </script>

</head>
<body onload='main()';>
  <div id='out'>
  </div>
</body>
</html>

Github repository about-javascript, path: /objects/Global-Object/function-properties/parseInt.html

See also

objects

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758198434, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/JavaScript/code-snippets/objects/global/parseInt(74): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78