JavaScript Object.hasOwn() Explained

JavaScript Logo

Object.hasOwn() – Checks if the object has the given property as its **own property**, not inherited.

๐Ÿ‘‰ Syntax

Object.hasOwn(obj, prop)

๐Ÿงช Example

const obj = { a: 1 };
console.log(Object.hasOwn(obj, 'a')); // true

Comments