JavaScript: Object.keys

By Xah Lee. Date: . Last updated: .
Object.keys(obj)
Return a Array of string property keys that are own and enumerable.
const obj = {"a":3, "b":4};

console.log( Object.keys(obj) ); // [ 'a', 'b' ]

The following example shows that Symbol key and non-enumerable properties are ignored.

const uu =
Object.create ( Object.prototype, {
 "a":
   { value : 3, writable: true, enumerable: true, configurable: true },
 "b":
   { value : 3, writable: true, enumerable: false, configurable: true },
 [Symbol("x")]:
   { value : 3, writable: true, enumerable: true, configurable: true },
});

const kk = Object.keys ( uu );

console.log( kk.length === 1); // true

console.log( kk[0] === "a" ); // true
BUY
ΣJS
JavaScript in Depth

JS Obj Reference

Object Object

prototype