DEV Community

Discussion on: If not ternary operator then what?

Collapse
 
jenbutondevto profile image
Jen

ES2020 now has the nullish coalescing operator ??. If the left operand is null or undefined, the right hand operand is used, if it’s not, then the left

const coalesced = undefined ?? 42
// 42
Enter fullscreen mode Exit fullscreen mode