1. Computing

ParseInt

By

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);
  1. About.com
  2. Computing
  3. JavaScript

©2014 About.com. All rights reserved.