JS Built-ins
ObjectObject.getPrototypeOfbeginner

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

Object.create(null) creates an object with no prototype. Object.getPrototypeOf returns null for such objects.

Challenge: Implement nullProtoIsNull() that creates an object with Object.create(null) and returns whether its prototype is null.

nullProtoIsNull() // β†’ true
πŸ’‘ Hints (1)
  • β€’ `Object.create(null)` creates an object completely outside the normal prototype chain.