Object static methods
Object.hasOwn()
Tests own property existence independent of its value or enumerability. Unlike in, does not search prototypes. Null or undefined object arguments throw.
Formal Syntax & Structure
javascript syntaxjavascript
Object.hasOwn(object, key)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| object | object or convertible primitive | Receiver to inspect. |
| key | property key | Name or symbol. |
Return Value
boolean
Whether the property is own.
Working Example
Example Snippetjavascript
console.log(Object.hasOwn({a:undefined},"a"),Object.hasOwn({},"toString"));