We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dd6c3bb commit 6d259b4Copy full SHA for 6d259b4
page/javascript-101/objects.md
@@ -33,3 +33,26 @@ var myObject = {
33
99999: 789
34
};
35
```
36
+## Iterating Over the Enumerable Properties of an Object:
37
+
38
+```
39
+var myObject = {
40
+ validIdentifier: 123,
41
+ "some string": 456,
42
+ 99999: 789
43
+};
44
45
+for ( var prop in myObject ) {
46
+ // Determine if the property is on the object itself.
47
+ // (not on the prototype)
48
+ if ( myObject.hasOwnProperty( prop ) ) {
49
+ console.log( "Property : " + prop + " ; value : " + myObject[ prop ] );
50
+ }
51
+}
52
53
+// Would log the following:
54
+// Please that the order is not guaranteed and may differ.
55
56
+// Property : 99999 ; value : 789
57
+// Property : validIdentifier ; value : 123
58
+// Property : some string ; value : 456
0 commit comments