What is the output of the following? “`js class Base { static greet() { return ‘Hello from Base’; } } class Child extends Base {} console.log(Child.greet()); console.log(Object.getPrototypeOf(Child) === Base); “`

JavaScript Developer Hard

JavaScript Developer — Hard

What is the output of the following? “`js class Base { static greet() { return ‘Hello from Base’; } } class Child extends Base {} console.log(Child.greet()); console.log(Object.getPrototypeOf(Child) === Base); “`

Key points

  • Child class inherits the static method greet() from the Base class
  • Object.getPrototypeOf(Child) returns the prototype of Child
  • The prototype of Child is Base
  • The output will be 'Hello from Base' and true

Ready to go further?

Related questions