JS Built-ins
← Object123 / 150
ObjecthasOwnPropertyintermediate

hasOwnProperty() β€” inherited from Object.prototype

πŸ“– Usage Example
// Check for own (non-inherited) property
const obj = { a: 1 }
obj.hasOwnProperty('a')          // β†’ true
obj.hasOwnProperty('toString')   // β†’ false

Use hasOwnProperty() to check whether a property exists directly on an object rather than on its prototype chain.

hasOwnProperty() β€” checking Object.prototype methods

Standard methods like toString, valueOf, and hasOwnProperty itself come from Object.prototype. They are NOT own properties of plain objects.

Challenge: Verify that standard Object.prototype methods are not own properties of plain objects.

πŸ’‘ Hints (1)
  • β€’ Object.prototype methods are inherited by all plain objects