$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · easy · #243

What is the output?

function f(a: number, b = a * 2): number {
  return b;
}
console.log(f(3), f(3, 0));
  1. 6 6
  2. 6 0
  3. 6 undefined
  4. 0 0
A default can use earlier parameters, so f(3) returns 6. Defaults apply only to undefined, so an explicit 0 is kept.
Play Problem Solving ▸