Advertisement
728x90
You can use the Object.getOwnPropertyNames() method which returns an array of all properties found directly in a given object. Let's see the usage of this in an example below:
javascript
1const newObject = {
2 a: 1,
3 b: 2,
4 c: 3,
5 };
6
7console.log(Object.getOwnPropertyNames(newObject));
8["a", "b", "c"];Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 25
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
281of476