gpt4 book ai didi

javascript - 在 Google 脚本中设置数字格式

转载 作者:行者123 更新时间:2023-12-02 18:20:13 25 4
gpt4 key购买 nike

如何提交表单,例如 1234 返回 1,234?

现在

可变价格 = 1234

请帮忙把这个变成 1,234

最佳答案

只需使用toLocaleString,如

var n = 1234;
alert(n.toLocaleString());

language spec

Produces a String value that represents this Number value formatted according to the conventions of the host environment’s current locale.

因此它应该使用用户首选的 digit grouping 来格式化数字,右边decimal separator .

关于javascript - 在 Google 脚本中设置数字格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18899804/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com