我在玩javascript,我想知道你是否可以让所有大于-1的值都评估为true,而所有从-1到down的值都评估为false?
现在1 == true
,如果你这样写,其他一切都等于假:
var i = 0;
if (i) {...} // I want this to be true
i = 1;
if (i) {...} // This is the only thing that is true
编辑:评估我的意思是我不进行比较,例如0 > -1
。我希望 JavaScript 将数字强制转换为布尔值。