4

100 >= 99.2 怎么可能是假的?

var ls = parseFloat(("100").replace(",", ".")).toFixed(1);
var val = parseFloat(("99,2").replace(",", ".")).toFixed(1);
alert(ls >= val); /*=> result is false  ...but it should be true */

ui文化是nl-BE

jsfiddle:http: //jsfiddle.net/Ed6VY/

4

1 回答 1

5

toFixed结果是一个字符串。字符串逐个字符进行比较。"9"之后"1",所以"99.2"大于"100.0"

于 2012-09-03T13:32:11.070 回答