Optional chaining and missing values

What value does the expression produce?

Examples

Worked example

Input
quantity = 0; quantity ?? 5
Expected output
0

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

Zero is neither null nor undefined, so the left value is kept.

Back to the lesson