Array of object keys in JavaScript

You can get an array of object keys. Let's see how it's done. Let's have the following object:

let obj = {a: 1, b: 2, c: 3};

Get an array of its keys:

let keys = Object.keys(obj);

Let's output this array to the console:


Get an array of keys of the next object:

let obj = {x: 1, y: 2, z: 3};