prop-keys
v2.0.0
Published
Returns an array of the keys of all properties (owned and inherited) of an object.
Downloads
70
Maintainers
Readme
prop-keys
Returns an array of the keys of all properties (owned and inherited) of an object.
Installation
Requires Node.js 6.0.0 or above.
npm i prop-keys
API
The module exports a single function.
Parameters
- Bindable:
obj
(object): The object whose property keys you want to get. - Object argument:
- Optional:
own
(boolean): If set totrue
, only the object’s “own” property keys are returned. If omitted or if set tofalse
, both owned and inherited property keys are returned. - Optional:
enumOnly
(boolean): If set totrue
, only the keys of properties defined with theenumerable
flag will be returned.
- Optional:
Return Value
An array of the keys of object properties.
Example
const keys = require('prop-keys')
keys({key: 'value'}, {own: true}) // ['key']
Related
- prop-entries: Same as this module, except it returns key-value pairs.
- prop-values: Same as this module, except it returns values.
- keys-array: Supports more than just Objects.