The parseInt function is provided to allow numbers to be easily converted between different number bases. All number bases between 2 and 36 are allowed as input and the base 10 equivalent of the number will be output by the function.
This function takes two parameters. The first parameter is the number to be converted to base 10 and the second parameter is the base that the number in the first parameter is in. If the second parameter is omitted then the first parameter is examined to attempt to determine what base it uses - if it starts with '0x' it is assumed to be base 16 and if it starts with '0' it is assumed to be base 8 (the strict mode recently introduced to JavaScript removes this alternative) and anything else is assumed to be base 10 and therefore will not be converted. Any trailing characters that are invalid for the number base will be discarded.
This example shows a function for converting numbers from base 16 (hexadecimal) to base 10 (decimal).
var dec;
h2d = function(h) {
return parseInt(h,16);
};
dec = h2d('ffcc00');
