Search code snippets, questions, articles...

Loop through object javascript

var items = {
    "item_1": "1",
    "item_2": "2",
    "item_3": "3"
}
for (var item in items) {
    console.log(items[item]);
}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.
Output
1
2
3

The code can be used to loop through an object which has some properties and its values. 

Example Demo

Was this helpful?
0 Comments