JS: Object.keys

JS: Object.keys

Object.keys ( obj )

Return a array of string property keys that are own and enumerable. (no symbol keys, and enumerable only)

[see JS: Property Attributes]

[see JS: Symbol Tutorial]

[see JS: List Properties]

const s = Symbol("x");

const u =
Object.create ( Object.prototype, {
    "p": { value : 3, writable: true, enumerable: false, configurable: true },
    "q": { value : 3, writable: true, enumerable: true, configurable: true },
    [Symbol()]: { value : 3, writable: true, enumerable: true, configurable: true },
});

// get all own string property keys that are enumerable
console.log ( Object.keys ( u ) ); // ['q']

// symbol key and non-enumerable properties are ignored
console.log ( Reflect.ownKeys ( u ) ); // [ 'p', 'q', Symbol() ]

Reference

ECMAScript 2015 §Fundamental Objects#sec-object.keys

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth