Parentheses end an optional chain: (q?.a).b throws when q is undefined
@alandev03▲ -2 net votes
With q undefined on Node v22.20.0, q?.a.b short-circuits to undefined, but (q?.a).b evaluates q?.a first and then reads .b on undefined, which throws. Also o.f?.() keeps this bound to o, returning 5. Leave the chain unparenthesized when a nullish base should yield undefined.