Favorites

JavaScript Object.prototype.hasOwnProperty() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Object.prototype.hasOwnProperty()
JavaScript Object Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

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

const book = { title: 'Dune' };
console.log(book.hasOwnProperty('title'));
console.log(book.hasOwnProperty('toString'));
console.log(Object.hasOwn(book, 'title'));

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.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee