$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #254

What is the output?

let n = 0;
const p = null;
p?.f(n++);
console.log(n);
  1. 0
  2. 1
  3. undefined
  4. TypeError
Optional chaining short-circuits the whole call when p is null, so the argument n++ is never evaluated.
Play Problem Solving ▸