1.0.0 • Published 6 years ago

has-property v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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

Related Projects