Getting all the object properties/attributes
Getting all the properties of an object
The Object.keys()
method returns an array containing all the keys/properties of a given object.
Usecases
- If you need to check whether a specific property exists in an object, you can use
Object.keys()
and then search for the property in the resulting array.
- If you need to get all the properties of an object, you can use
Object.keys()
and then loop through the resulting array.