Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to iterate over keys in object javascript

var p = {
    "p1": "value1",
    "p2": null,
    "p3": "value3"
};

for (var key in p) {
    if (p.hasOwnProperty(key)) {
        console.log(key + " -> " + p[key]);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #iterate #keys #object #javascript
ADD COMMENT
Topic
Name
8+2 =