In today’s quick tip, you’ll learn about Object.keys method in JavaScript. This method is used to get the keys of an object as an array. Let’s try to understand it using an example:

let obj = {"name": "roy", "age" : 24};
console.log(Object.keys(obj))

// Output
["name", "age"]

As seen in the above code, variable obj is an Object. Object.keys method returns an array of keys in obj object.