get-own-property
Version:
Retrieves a property only if hasOwnProperty() is true.
23 lines (14 loc) • 478 B
Markdown
if [`hasOwnProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty) is true.
```bash
npm install get-own-property --save
```
```javascript
const getOwnProperty = require('get-own-property')
const obj = {hello: 'world'}
getOwnProperty(obj, 'hello') // 'world'
typeof obj.toString // 'function'
getOwnProperty(obj, 'toString') // undefined
```
Retrieves a property only