1var obj = {
2 first: "John",
3 last: "Doe"
4};
5
6//
7// Visit non-inherited enumerable keys
8//
9Object.keys(obj).forEach(function(key) {
10
11 console.log(key, obj[key]);
12
13});
1Add thisvar p = {
2 "p1": "value1",
3 "p2": "value2",
4 "p3": "value3"
5};
6
7for (var key in p) {
8 if (p.hasOwnProperty(key)) {
9 console.log(key + " -> " + p[key]);
10 }
11}