1Object.entries(obj).forEach(
2 ([key, value]) => console.log(key, value)
3);
1var obj = { first: "John", last: "Doe" };
2
3Object.keys(obj).forEach(function(key) {
4 console.log(key, obj[key]);
5});
1for (var property in object) {
2 if (object.hasOwnProperty(property)) {
3 // Do things here
4 }
5}
6
1var person={
2 first_name:"johnny",
3 last_name: "johnson",
4 phone:"703-3424-1111"
5};
6for (var property in person) {
7 console.log(property,":",person[property]);
8}
1const fruits = { apple: 28, orange: 17 }
2
3for(key in fruits){
4 console.log(key)
5}