我正在JavaScript中做一個簡單的比較,但它不工作。 這裏是腳本爲什麼在JavaScript中「1.0」不等於「+1.0」?
var value = '1.0';
var minLimit = '+0.5';
var maxLimit = '+999';
if (value >= minLimit && value <= maxLimit) {
console.log(value);
}
else
{
console.log('not matched');
}
有什麼我缺少比較? 這裏是小提琴http://jsfiddle.net/9ouwkyyt/
,因爲你正在做一個字符串比較 - http://jsfiddle.net/arunpjohny/9ouwkyyt/1/ – 2014-09-30 10:22:04