4 ms·
var a=NaN, b=1; a<b ? -1 : (a>b ? 1 : 0); // 0 var a="a", b=1; a<b ? -1 : (a>b ? 1 : 0); // 0 The switch and if statements would return undefined in these cas
by crznp 7y ago
var a=NaN, b=1; a<b ? -1 : (a>b ? 1 : 0); // 0
var a="a", b=1; a<b ? -1 : (a>b ? 1 : 0); // 0
The switch and if statements would return undefined in these cases. Or others threw an error if none of the conditions matched, that would work too.