2.2 KiB
2.2 KiB
has-own-property-x
Used to determine whether an object has an own property with the specified property key.
See: 7.3.11 HasOwnProperty (O, P)
Version: 3.2.0
Author: Xotic750 Xotic750@gmail.com
License: MIT
Copyright: Xotic750
module.exports(object, property) ⇒ boolean ⏏
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:
TypeErrorIf 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
var hasOwnProperty = require('has-own-property-x');
var o = {
foo: 'bar'
};
hasOwnProperty(o, 'bar'); // false
hasOwnProperty(o, 'foo'); // true
hasOwnProperty(undefined, 'foo');
// TypeError: Cannot convert undefined or null to object