← TechnologyThe essentials of

Object.hasOwn(): existing field with undefined

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 13:13 · Updated: 22 Oct 2026 13:13

AI source check: 21 Oct 2026 12:40. This is not editorial approval.

In a few sentences

In brief

The presence of a property is different from the presence of a useful value.

Useful to know

Object.hasOwn(obj, key) checks whether the property belongs to the object itself. For {price: undefined}, check for "price" returns true, despite value undefined. Inherited properties do not pass . [1]

This is useful in a partial update, when a missing field means "do not change", and a filed field has a separate meaning. After the availability check, validate the value as well. Do not use obj.price's truthfulness for the same task: zero, empty string, and false can be consciously submitted eligible data.

Sources

For further detail and to check the information:

  1. [1] MDN — Object.hasOwn ↗