$ npm install get-own-enumerable-keys-x
Like Reflect.ownKeys but gets only enumerable properties.
module.exports(target)
⇒ Array
⏏This method returns only the enumerable own keys of an object.
Kind: Exported function
Returns: Array
- The enumerable own keys.
Throws:
typeError
- If target is null or undefined.Param | Type | Description |
---|---|---|
target | Object |
The target. |
Example
import getOwnEnumerableKeys from 'get-own-enumerable-keys-x';
const obj = {bar: 1, foo: 2};
Object.defineProperty(obj, Symbol('first'), {
enumerable: false,
value: 'first',
});
const symbol = Symbol('second');
Object.defineProperty(obj, symbol, {
enumerable: true,
value: 'second',
});
console.log(getOwnEnumerableKeys(obj)); // ['bar', 'foo', symbol]
© 2010 - cnpmjs.org x YWFE | Home | YWFE