cf.completefrontend

Predict the outputHard

How far does optional chaining short-circuit in this code?

What does this log?
const user = { profile: null, greet: undefined };
let calls = 0;
 
console.log(user.profile?.name.first);
console.log(user.greet?.(calls++));
console.log(calls);
console.log(user.settings?.theme ?? "light");
console.log((user.profile?.name).first);
console.log("done");

The answer

Work out every line it logs, in order. Then check.

Checking your sign-in…