How do I display large numbers with commas? HTML

后端 未结 3 1961
耶瑟儿~
耶瑟儿~ 2020-12-29 07:18

I am wanting to display large numbers more nicely with commas. So if the number was say 123456789, it would display 123,456,789. I have looked around but I only found code t

3条回答
  •  滥情空心
    2020-12-29 07:44

    There's a simpler syntax for toLocaleString:

    Number(x).toLocaleString();
    

    This lets you drop the number in as a variable instead of converting the number into an object.

提交回复
热议问题