javascript parseFloat '500,000' returns 500 when I need 500000

DanC picture DanC · Jul 8, 2010 · Viewed 35.1k times · Source

How would it be a nice way of handling this?

I already thought on removing the comma and then parsing to float.

Do you know a better/cleaner way?

Thanks

Answer

James picture James · Jul 8, 2010
parseFloat( theString.replace(/,/g,'') );