cf.completefrontend

Predict the outputHard

What does this log after the variables holding two recursive functions are reassigned?

What does this log?
let factorial = function (n) {
  return n <= 1 ? 1 : n * factorial(n - 1);
};
let factorial2 = function fact(n) {
  return n <= 1 ? 1 : n * fact(n - 1);
};
 
const a = factorial;
const b = factorial2;
factorial = factorial2 = () => 0;
 
console.log(a(5), b(5));
console.log(typeof fact);

The answer

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

Checking your sign-in…