javascript
Loop through object javascript
var items = {
"item_1": "1",
"item_2": "2",
"item_3": "3"
}
for (var item in items) {
console.log(items[item]);
}
Output
1
2
3
2
3
The code can be used to loop through an object which has some properties and its values.
Example Demo
Was this helpful?
Similar Posts
- Loop through object on template Vuejs
- Loop through an object using map in React
- JavaScript ES6 filtering object with multiple params
- Optional Chaining on Javascript Object
- Convert object {key: value} to Array [[key, value]] Javascript
- Get all keys from an object using Javascript
- Get all values as array items from an Object in Javascript