has-property
v1.0.0
Published
Tests whether an object possesses a property. Like hasOwnProperty(), but checks the entire prototype chain.
Downloads
2
Readme
has-property
A Node.js module which tests whether an object possesses a property. It's like hasOwnProperty()
but it checks the entire prototype chain.
Installation
npm install has-property --save
Usage
const hasProperty = require('has-property')
class Obj {
get clsProp () { return 'Hello world' }
}
const obj = new Obj()
obj.clsProp // 'Hello world'
obj.hasOwnProperty('clsProp') // false
hasProperty(obj, 'clsProp') // true
obj.ownProp = true
obj.hasOwnProperty('ownProp') // true
hasProperty(obj, 'ownProp') // true