cf.completefrontend

Predict the outputMedium

Which destructuring defaults are used here, and what happens with null?

What does this log?
const { a = 1, b = 2, c = 3, d = 4 } = { a: undefined, b: null, c: 0 };
console.log(a, b, c, d);
 
function greet({ name = "guest" } = {}) {
  return `hi ${name}`;
}
 
console.log(greet());
console.log(greet({ name: null }));
console.log(greet(null));

The answer

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

Checking your sign-in…