1 2 |
const userInput = ''; const result = userInput ?? 'Default'; |
Is userInput null or undefined? NO. So don’t do anything.
1 2 |
const userInput = null; const result = userInput ?? 'Default'; |
Is userInput null or undefined? YES. So we result is assigned to ‘Default’.