Object.hasOwnProperty() (Method)

A method that can be used to test whether a property exists and belongs to the receiving object.

Availability:

ECMAScript edition - 3
JavaScript - 1.5
JScript - 5.5
Internet Explorer - 5.5
Netscape - 6.0
Property/method value type:Boolean primitive
JavaScript syntax:-myObject.hasOwnProperty(aName)
Argument list:aNameThe name of a property to test for

For this method to yield a Boolean true value, the property named in the argument must exist and must belong to the receiving object. If the property is inherited from a prototype or earlier ancestor then this method returns false.

This method would be useful if it could test for the existence of a property in the inheritance chain. There is an internal HasProperty() method but the ECMA standard indicates that it is not exposed to the script interface.

See also:HasProperty()

Cross-references:

ECMA 262 edition 3 - section - 15.2.4.5