How to get properties values of a object without knowing their keys in Javascript?
Question
So there is a javascript object like1
2
3
4
5var objects = {
type:"Fiat",
model:"500",
color:"white"
}
If the key names are random, and we don’t know. How to get each property’s value with a loop?
Answer
By using for..in..
loop:1
2
3for(var key in objects) {
var value = objects[key];
}
Reference
This is the end of post