4
100> = 99.2是否爲假?javascript中的浮點比較
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/
@OP;您可以使用'alert(typeof ls)'來驗證它是一個字符串的事實;' – h2ooooooo
更多解釋在這裏:http://stackoverflow.com/questions/2283566/tofixed-returns-a-string-in-javascript –