【发布时间】:2022-11-20 20:26:42
【问题描述】:
why Null Coalescing is not working with ternary operator. I would expect to get tdy.
const test = {
todo: {
day: 'tdy'
}
}
const filterDayRange = [{
day: 'mon'
}]
const result =
test.todo?.day ?? filterDayRange.length > 0 ? filterDayRange[0].day : 'tdy';
console.log(result)
// expected Output: tdy
【问题讨论】:
标签: typescript