views:

107

answers:

2

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#)

+1  A: 

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,''))
Tim Goodman
Really Really Appreciate It // But How Can i Convert that string (with commas) to a number ?
LostLord
Really thanks for your Edit... -> (Mean For Tim Goodman)
LostLord
A: 

I think you'll find what you need in there :) http://stackoverflow.com/questions/610406/javascript-printf-string-format

Jad