JavaScript Internals (521 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)
How can you get the list of keys of any object
You can use the Object.keys() method which is used to return an array of a given object's own property names, in the same order as we get with a normal loop. For example, you can get the keys of a user object,
javascript
const user = {
name: "John",
gender: "male",
age: 40,
};
console.log(Object.keys(user)); //['name', 'gender', 'age']