Javascript parseInt Function
Javascript parseInt function converts the string type value into integer. If floating point number is passed to the parseInt function then it returns the integer value truncating precision point values. We discussed about Javascript parseFloat function in the previous article, the javascript parseInt function also follows the same rules that parseFloat function uses. parseInt function reads the first character of string passes if it is a numeric value then it parses the value into integer. If string starts with string character then parseInt function becomes unable to parse the string value and returns NaN.
JavaScript Functions Examples:
You can see the live samples and examples of JavaScript Functions from the following links:
Only leading space character is allowed in the string value passed to the parseInt function. Otherwise parseInt function returns NaN i.e. Not a Number.
Javascript parseInt Function Syntax
parseInt(string);
parseInt function takes string type value as argument that is converted into number or integer type.
Javascript parseInt Function Examples
document.write(parseInt("123") + "<br />");
document.write(parseInt(" 123") + "<br />");
document.write(parseInt(" 123 ") + "<br />");
document.write(parseInt("123.22") + "<br />");
document.write(parseInt("123a") + "<br />");
document.write(parseInt("123 a") + "<br />");
document.write(parseInt("123 456 789") + "<br />");
document.write(parseInt("number 123") + "<br />");
Note: In above examples parseInt function returned 123 for the input string value "123.22". parseInt function truncates the floating point precision values. Another thing Javascript parseInt function allows leading and trailing space characters but return NaN for the string value not starting with number. E.g. in above code parseInt function returned NaN for "number 123".
Continue to next tutorial: Javascript parseInt using Radix to learn how to convert the decimal numbers into other number system.

* will not be published
* hint: http://www.example.com