Skip to content

kt3k/get-property-names

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-property-names v1.0.0

Circle CI codecov js-standard-style

Non-own version of Object.getOwnPropertyNames()

Install

npm install get-property-names

Usage

const getPropertyNames = require('get-property-names')

const a = {a: 1, b: 2}

getPropertyNames(a)
//=> this returns ['a', 'b']

class A {
  foo () {}
}

class B extends A {
  bar () {}
}

getPropertyNames(new B())
//=> this returns `['constructor', 'bar', 'foo']`

class C extends A {
  constructor () {
    super()
    this.baz = 1
  }
}

getPropertyNames(new C())
//=> this returns `['baz', 'constructor', 'foo']`

As the examples above, getPropertyNames returns the list of all the property names of an object, which includes non enumerable properties in its prototype chain.

License

MIT

About

Non-`own` version of `Object.getOwnPropertyNames()`

Resources

License

Stars

Watchers

Forks

Packages

No packages published