Anjan Dutta
Javascript loop through object
Javascript loop through object
To loop through a javascript object, first, we must extract the keys of that object in an array. Then loop through that array and take out every array value to get property from that object.
let person = {name: 'John', age: 30, address: '18/1, Dover lane' }
for (let key in person) {console.log(person[key]);}
This way we can iterate through an object’s properties.
Exception
Only in case if the property is created using defineProperty
and the enumerable is set to false then this method will not access that property.