小数号中的JavaScript中的字符串值如何转换字符串值
如何使用JavaScript将r $ 800,000.00的弦类型转换为800000小数类型?
How to convert R$ 800,000.00 in string type to 800000 decimal type using JavaScript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你为什么不使用
currenyvalueInt = parseint(currencyValuestring.split(“”)[1])
Why don’t you just use
currenyValueInt = parseInt(currencyValueString.split(" ")[1])
您可以通过替换数字和十进制分隔符以外的所有内容来消毒字符串,然后用
number()
或简单地在其前面添加+
表达:You sanitize the string by replacing everything but digits and the decimal separator and then cast it to a Number, either with
Number()
or by simply adding a+
in front of the expression: