Widely available Recommended for direct property checks, especially when objects may not inherit the standard prototype methods safely.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
93
93
92
15.4
93
15.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
const obj = Object.create(null);
obj.key = 'value';

// obj.hasOwnProperty('key'); // Error!
Object.hasOwn(obj, 'key'); // true

Live demo

Object.hasOwn Basics

Object that property has or confirm.hasOwnProperty. safeall alternative.

PreviewFullscreen

HasOwnProperty and. Comparison

also safeall to behavior. with Object.hasOwn is Object.create(null).

PreviewFullscreen

Practical Example: formvalid-tion

Object to requiredki- that include or check.

PreviewFullscreen

Use cases

  • Filtering own properties

    Distinguish local data from inherited helpers when iterating or validating object input.

  • Safer guard conditions

    Confirm a field exists directly on a record before reading or transforming it.

Cautions

  • hasOwn only checks property ownership, not whether the value is meaningful, valid, or non-empty.
  • Direct property checks do not replace schema validation for complex external data.

Accessibility

  • If ownership checks influence visible labels or options, keep the resulting UI states explicit so users understand what is available.