Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xotic750/has-own-property-x
Used to determine whether an object has an own property with the specified property key.
https://github.com/xotic750/has-own-property-x
browser ecmascript hasownproperty nodejs
Last synced: 2 months ago
JSON representation
Used to determine whether an object has an own property with the specified property key.
- Host: GitHub
- URL: https://github.com/xotic750/has-own-property-x
- Owner: Xotic750
- License: mit
- Created: 2015-12-03T21:18:22.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:54:47.000Z (about 2 years ago)
- Last Synced: 2024-04-25T19:21:23.151Z (9 months ago)
- Topics: browser, ecmascript, hasownproperty, nodejs
- Language: JavaScript
- Homepage:
- Size: 3.49 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## has-own-property-x
Used to determine whether an object has an own property with the specified property key.
### `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**:-
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
```