Looping Through Object Properties with for…in in Javascript


Iterate over each property in an object.

Source Code

let person = {name: "John", age: 30};
for (let key in person) {
  console.log(key + ": " + person[key]);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments