$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #183

What is the output?

const o = {};
console.log(o.a?.b);
  1. undefined
  2. TypeError
  3. null
  4. {}
Optional chaining short-circuits the whole expression to undefined instead of throwing.
Play Problem Solving ▸