Nullish coalescing operator ?? example
Just a simple example of using ??
According to MDN it is the fifth most used operator directly lower than || and directly higher than the conditional ternary operator. I was surprised at this as I've seen ternaries used a lot, but. have only just discovered ??
Here is a typical use case scenario
instead of
let name = itemName !== undefined ? itemName : null
use
let name = itemName ?? null
for the same result.