JS: Object.keys

JS: Object.keys

Object.keys ( obj )

Return a array of string property keys that are own and enumerable.

[see JS: Property Attributes, writable, enumerable, configurable]

[see JS: List Properties]

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

[see JS: Symbol Tutorial]

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. CSS
  3. JavaScript
  4. JS Obj Ref
  5. DOM
  6. SVG
  7. Blog