JS Built-ins
ObjectObject.getPrototypeOfbeginner

Object.getPrototypeOf() β€” plain object 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()

Object.getPrototypeOf(obj) returns the prototype of obj. For plain objects created with {} or new Object(), the prototype is Object.prototype.

Challenge: Implement plainProtoIsObjectProto() that creates {} and returns whether its prototype is Object.prototype.

plainProtoIsObjectProto() // β†’ true
πŸ’‘ Hints (1)
  • β€’ `Object.getPrototypeOf({})` returns `Object.prototype` β€” the root of most prototype chains.