js中两个数值运算时出现多位小数

[img][/img]
var price = parseFloat('' == record.get('price') ? 0 : record.get('price'));
var quantity = parseFloat('' == record.get('quantity') ? 0 : record.get('quantity'));

var cost = parseFloat(price * quantity);
cost = cost.toFixed(2);
record.set('cost',cost);

你可能感兴趣的:(JavaScript)