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)