Thursday, February 19, 2009

Converting a string data type to float in javascript?

To convert a value from string to float, we have to use the function or method "parseFloat() to convert a string value to float.

Example:

parseFloat("4.333"); // 4.333
parseFloat("5aaa"); // 5
parseFloat("6e2"); // 600
parseFloat("aaa"); // NaN (means "Not a Number")

No comments: