Coalesce
The coalesce ??
operator can be used to provide default values when the given path does not exist, or causes some error.
The operator will pass through to the secondary value if:
A given map key doesn't exist
A given array index doesn't exist
The given expressions returns
null
An operation is performed on an invalid type
Examples
Check if a property or index exists
Default values when something doesn't exist
Chaining
The coalesce operator can be chained, with items towards the left taking prescedence.
Last updated