javascript - Convert a string to a number, an example is a="2,322.222", b='1,211.21', how to perform subtraction in angualr
伊谢尔伦
伊谢尔伦 2017-05-16 13:44:20
0
2
527

The example is a="2,322.222",b='1,211.21', how to perform subtraction in angualr

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
刘奇
function(a, b) {
    a = a.replace(',', '');
    b = b.replace(',', '');
    return (+a - +b).toFixed(2);
}
过去多啦不再A梦

Use split(',') and press ',' to divide it into multiple arrays and judge based on the length. For example, a is 21000 and b is 11000. If there are more commas, it is judged based on the length. If the length is 3, the subscript is When 0 is 10001000, consider the Math.pow(10,n * 3) method and convert it into numbers for subtraction. You can try it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template