JavaScript Object.prototype.hasOwnProperty() Method
The hasOwnProperty() method checks whether an object has a property of its own rather than an inherited one. Object.hasOwn() is the modern replacement.
Description
The hasOwnProperty() method returns whether the object has the given property as its own property. It's inherited by almost every object from Object.prototype.
It doesn't work on objects without a prototype, such as those from Object.create(null), and can be overridden by an object's own property of the same name. Object.hasOwn(obj, prop) avoids both problems and is recommended in new code.
You can still use it safely on any object by calling it from Object.prototype, as in Object.prototype.hasOwnProperty.call(obj, key), which is the pattern you'll see in older libraries. It's equivalent to Object.hasOwn(), which is shorter and now supported everywhere.
Syntax
obj.hasOwnProperty(prop)Parameters
- propThe property name or symbol to check.
Return Value
true if the object has the property as its own, otherwise false.
Example
Browser Support
The following information will show you the current browser support for the Object.prototype.hasOwnProperty() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





