JS Built-ins
ObjectObject.getPrototypeOfbeginner

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

Arrays are instances of Array, so their prototype is Array.prototype, not Object.prototype directly.

Challenge: Implement arrayProtoIsArrayProto() that returns whether the prototype of [] is Array.prototype.

arrayProtoIsArrayProto() // β†’ true
πŸ’‘ Hints (1)
  • β€’ Arrays are instances of `Array`, whose prototype chain is `[] β†’ Array.prototype β†’ Object.prototype β†’ null`.