const obj = { name: "Human", age: 26, location: "World", role: "Developer" };
console.log(Object.keys(obj)); // [ 'name', 'age', 'location', 'role' ]
// Updating setting for `name` property
Object.defineProperty(obj, "name", {
enumerable: false,
});
console.log(Object.keys(obj)); // [ 'age', 'location', 'role' ]
const objKeys = [];
for (const key in obj) objKeys.push(key);
console.log(objKeys); // [ 'age', 'location', 'role' ]
Thanks for reading π
Follow @codedrops.tech for daily posts.
Instagram β Twitter β Facebook
Micro-Learning β Web Development β Javascript β MERN stack β Javascript
codedrops.tech
Top comments (0)