JS Built-ins
ObjectObject.hasOwnbeginner

Object.hasOwn() β€” missing property returns false

πŸ“– Usage Example
// Check if a property is directly on the object
const obj = { name: 'Alice' }
Object.hasOwn(obj, 'name')      // β†’ true
Object.hasOwn(obj, 'toString')  // β†’ false

Use Object.hasOwn() to reliably check if a property is an own property, without being fooled by inherited properties.

Object.hasOwn() β€” missing property

Object.hasOwn returns false for properties that do not exist on the object at all.

Challenge: Implement isMissing(obj, key) that returns true when the property does NOT exist as an own property.

isMissing({ a: 1 }, 'b') // β†’ true
isMissing({ a: 1 }, 'a') // β†’ false
πŸ’‘ Hints (1)
  • β€’ Negate `Object.hasOwn` to check for absence.