+ 2

Is there a way to format strings in java script?

java script built in functions

2nd Feb 2018, 9:45 PM
Jason Simmons
Jason Simmons - avatar
3 Antworten
+ 7
decimal places - toFixed(n) formatting - toLocaleString(<locale>) example: var x = 10000000 alert(x.toLocaleString('en-US')) // outputs 10,000,000 more about locales: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
2nd Feb 2018, 10:35 PM
Burey
Burey - avatar
+ 5
mind giving an example? format how exactly?
2nd Feb 2018, 10:05 PM
Burey
Burey - avatar
+ 2
formatting how many decimal places are shown or putting commas in large numbers such as 1,000,000.00
2nd Feb 2018, 10:15 PM
Jason Simmons
Jason Simmons - avatar