cf.completefrontend

Predict the outputHard

A parent constructor calls this.init() and the child defines init as an arrow field. What does this log?

What does this log?
class Parent {
  constructor() {
    console.log(this.constructor.name);
    this.init();
  }
  init() {
    console.log("Parent method");
  }
}
 
class Child extends Parent {
  init = () => {
    console.log("Child arrow");
  };
}
 
const child = new Child();
child.init();
console.log(Object.hasOwn(child, "init"));

The answer

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

Checking your sign-in…