Default if Nullish

Variables & Types ยท medium

Implement `withDefault(value, fallback)` returning `value` unless it is null or undefined, in which case return `fallback`. Note that `0` and empty string are valid values.

Learning resources

Loading...

Run your code to see results.