Windows Dev Center

hasOwnProperty Method (Object) (JavaScript)

Determines whether an object has a property with the specified name.



Required. Instance of an object.


Required. String value of a property name.

The hasOwnProperty method returns true if object has a property of the specified name, false if it does not. This method does not check the properties in the object's prototype chain; the property must be a member of the object itself.

This property is not supported on host objects for Internet Explorer 8 and below.

In the following example, all String objects share a common split method. The following code will display false and true.

var s = new String("Sample");

// Output:
// false
// true

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

© 2015 Microsoft