How to Get keys of a JavaScript Object
getObjectKeys() will return an array of keys of an object
var obj = {
name:"John Doe",
age:23,
sex:"Male"
};
// returns an array of keys
function getObjectKeys(obj){
var keys=[];
Object.entries(obj).forEach(([key])=>{
// console.log(key);
keys[]=key;
});
return keys;
}
console.log(getObjectKeys(obj));
// (3) ["name", "age", "sex"]
ALTERNATE TITLES