Jquery parseInt - String to Integer

Converting a string to integer to perform arithmetical operations

var myString = '1234';

var myInteger;

myInteger = parseInt(myString);


To convert a string to decimal:

var myString = '1234.098';

var myInteger = parseInt(myString); // result = 1234
var myNumber = parseFloat(myString); // result = 1234.098

To reduce the number of decimals:

var myNumber = 1234.098;

myNumber = myNumber.toFixed(2); // result = 1234.09


Sagar (28.04.2012)
Nice explanation! The parseInt() function has a syntax parseInt(string, radix). You might have to provide radix parameter sometimes to avoid few issues. Below is the post that explains this issue with its solution. http://swsharinginfo.blogspot.in/2011/09/jquery-parseint-without-radix-may-cause.html

Lauren (25.03.2011)
Needed to convert string to integer and parseInt did the trick!

george (13.08.2010)
I've searched and it doesn't seem to exist something jQuery specific

pedro (12.06.2010)
that's a standard jscript function,not a jquery function...