valueOrDefault
ValueOrDefault is a programming pattern and, in some languages, a utility that returns a given value if it is not null or undefined; otherwise, it returns a specified default value. It is commonly used to simplify handling optional data and to prevent null reference errors.
In practice, valueOrDefault can be implemented as a small helper or realized through language features. Different
Common use cases include supplying defaults for configuration values, function parameters, and UI labels when input
Caveats include distinguishing between null/undefined and other falsey values. A value of 0, an empty string,
See also: null-coalescing operator, Elvis operator, Optional type.