JS Built-ins
ObjectObject.getPrototypeOfintermediate

Object.getPrototypeOf() β€” class instance prototype

πŸ“– Usage Example
// Get the prototype of an object
const arr = []
Object.getPrototypeOf(arr) === Array.prototype   // β†’ true
Object.getPrototypeOf({}) === Object.prototype   // β†’ true

Use Object.getPrototypeOf() to retrieve the prototype of an object, allowing you to inspect its inheritance chain.

Object.getPrototypeOf() β€” classes

When you create an instance with new MyClass(), the prototype is MyClass.prototype.

Challenge: Implement classInstanceProto() that creates a class Foo, instantiates it, and returns whether the prototype is Foo.prototype.

classInstanceProto() // β†’ true
πŸ’‘ Hints (1)
  • β€’ `new Foo()` sets the instance prototype to `Foo.prototype`.