Object.hasOwn() - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

Object.prototype.hasOwnProperty()

Note: Object.hasOwn() is intended as a replacement for Object.prototype.hasOwnProperty().

null-prototype objects

The Object.hasOwn() method returns true if the specified property is a direct property of the object — even if the property value is null or undefined. The method returns false if the property is inherited, or has not be

Checking if an Array index exists

The elements of an Array are defined as direct properties, so you can use hasOwn() method to check whether a particular index exists:

Enumerability and ownership of properties

Object.getOwnPropertyNames()

Inheritance and the prototype chain

Learn how to contribute

This page was last modified on Jul 20, 2025 by MDN contributors.

defineProperties()

getOwnPropertyDescriptor()

getOwnPropertyDescriptors()

getOwnPropertySymbols()

preventExtensions()

__defineGetter__()

__defineSetter__()

__lookupGetter__()

__lookupSetter__()