Advertisement
728x90
You can use the Object.keys() method which is used to return an array of a given object's own property names, in the same order as we get with a normal loop. For example, you can get the keys of a user object,
javascript
1const user = {
2 name: "John",
3 gender: "male",
4 age: 40,
5 };
6
7console.log(Object.keys(user)); //['name', 'gender', 'age']Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 32
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
202of476