我在编写脚本时发现了一个错误,而且我遇到了麻烦,确切指出导致问题的原因。具体做法是:这里发生了什么样的Javascript类型转换?
"49px" < 50 === false
有两种不同的转换,我能想到的在这里:
parseInt("49px") < 50 === true
那么,为什么这个值为false:
49 < 50 === true
"49px" < "50" === true
"49" < 50 === true // just for the hell of it
我有固定的呢?到底发生了什么?
查看[Abstract Relational Comparison Algorithm](http://es5.github.com/#x11.8.5)... – 2011-05-13 00:41:53
修复不足。 Number(“49px”)发生,parseInt/Float行为有所不同 – user422039 2011-05-13 02:36:17
你没有在解析int中指定一个基数? https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseInt现在就做,但还不算太晚! – Incognito 2011-05-13 02:42:36