On this page
  1. Object.hasOwn
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Object.hasOwn

Prev: fromEntries | Up: Object | Next: assign
Rel: Object, Object & Reflect Guide
Ref: MDN Web Docs — Object.hasOwn
Tags: #public #web #javascript #builtins #object #tier/core


Signature & Overview

Object.hasOwn(obj, prop)

Returns true if obj has prop as its own (non-inherited) property (ES2022).

Notes & Pitfalls

Example

const dict = Object.create(null);
dict.key = 1;
console.assert(Object.hasOwn(dict, "key") === true);
console.assert(Object.hasOwn(dict, "toString") === false);

Linked from

Related notes