Is there any function in Javascript for formatting number and strings ?
I am looking for a way for thousand separator for string or numbers... (Like String.Format In c#)
Is there any function in Javascript for formatting number and strings ?
I am looking for a way for thousand separator for string or numbers... (Like String.Format In c#)
According to this reference there isn't a built in function for adding commas to a number. But that page includes an example of how to code it yourself.
Edit: To go the other way (convert string with commas to number), you could do something like this:
parseFloat("1,234,567.89".replace(/,/g,''))
I think you'll find what you need in there :) http://stackoverflow.com/questions/610406/javascript-printf-string-format