has-property

v1.0.0
Tests whether an object possesses a property. Like hasOwnProperty(), but checks the entire prototype chain.

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

npm i has-property

Metadata

  • MIT
  • Whatever
  • John Lamansky
  • released 11/23/2017

Downloads

Maintainers