js +与?优先级

var val = 'smtg';
console.log('Value is ' + (val === 'smtg') ? 'Something' : 'Nothing');

// A. Value is Something
// B. Value is Nothing
// C. NaN
// D. other

答案是D

输出

"Something"

猜你喜欢

转载自www.cnblogs.com/sea-stream/p/10740979.html