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)