Learn JavaScript
Optional Chaining

Short Circuiting

When we use optional chaining ?., the execution stops or short-circuits if the value before ?. does not exist. It does not evaluate the value that is after ?..

In the example given above, the user does not contain anything i.e. null. Therefore, ?. skips the evaluation of x++ and the value of x remains the same.