1for (var property in object) {
2 if (object.hasOwnProperty(property)) {
3 // Do things here
4 }
5}
6
1const object = { a: 1, b: 2, c: 3 };
2
3for (const property in object) {
4 console.log(`${property}: ${object[property]}`);
5}
1var person = {"name":"Rasel", age:26};
2
3for (var property in person) {
4 console.log(person[property]);
5}
1const fruits = {
2 apple: 28,
3 orange: 17,
4 pear: 54,
5}
6
7const keys = Object.keys(fruits)
8console.log(keys) // [apple, orange, pear]
9