Used to determine whether an object has an own property with the specified property key.
npm install has-own-property-x href="https://travis-ci.org/Xotic750/has-own-property-x"
title="Travis status"> src="https://travis-ci.org/Xotic750/has-own-property-x.svg?branch=master"
alt="Travis status" height="18">
href="https://david-dm.org/Xotic750/has-own-property-x"
title="Dependency status"> alt="Dependency status" height="18"/>
href="https://david-dm.org/Xotic750/has-own-property-x?type=dev"
title="devDependency status"> alt="devDependency status" height="18"/>
href="https://badge.fury.io/js/has-own-property-x"
title="npm version"> alt="npm version" height="18">
href="https://www.jsdelivr.com/package/npm/has-own-property-x"
title="jsDelivr hits"> alt="jsDelivr hits" height="18">
href="https://bettercodehub.com/results/Xotic750/has-own-property-x"
title="bettercodehub score"> alt="bettercodehub score" height="18">
href="https://coveralls.io/github/Xotic750/has-own-property-x?branch=master"
title="Coverage Status"> alt="Coverage Status" height="18">
Used to determine whether an object has an own property with the specified property key.
The hasOwnProperty method returns a boolean indicating whether
the object has the specified property. Does not attempt to fix known
issues in older browsers, but does ES6ify the method.
Kind: Exported function
Returns: boolean - true if the property is set on object, else false.
Throws:
- TypeError If object is null or undefined.
| Param | Type | Description |
| -------- | ------------------------------------------ | ------------------------------------------- |
| object | Object | The object to test. |
| property | string \| Symbol | The name or Symbol of the property to test. |
Example
``js
import hasOwnProperty from 'has-own-property-x';
const o = {
foo: 'bar',
};
console.log(hasOwnProperty(o, 'bar')); // false
console.log(hasOwnProperty(o, 'foo')); // true
hasOwnProperty(undefined, 'foo'); // TypeError: Cannot convert undefined or null to object
``