1. Home
  2. Computing & Technology
  3. JavaScript

ParseInt

By , About.com Guide

Definition: The parseInt built-in function extracts the integer portion of whatever value is passed to it. One common use for this function is to extract the major version number of thecurrent browser from the version field discarding the minor version number (eg. 7.53 becomes just 7). This is not a reserved word so you can declare your own variable or function called parseInt but if you do then you will not be able to use the built-in function.

Note that if the number passed to the parseInt function has a leading zero (eg. 07) then that number will be considered to be an octal (base 8) number instead of a decimal (base 10) number.

Examples:
browserVersion = parseInt(navigator.appVersion);
Explore JavaScript
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. JavaScript
  4. Reference
  5. Javascript Glossary - Parseint

©2009 About.com, a part of The New York Times Company.

All rights reserved.