Here's a sample. My concern is both seem to do the job. which of them to prefer?
var fooArr = [{ "bar": {"blah": 9 } }];
for(var i in fooArr) {
var value = fooArr[i].bar.blah;
console.log(value); //checking in firebug console
}
var fooObj = { "bar": {"blah": 9 } };
for(var i in fooObj) {
var value = fooObj[i].blah;
console.log(value); //checking in firebug console
}
Also, the following seems to be not valid, Any way of avoiding array notation.
var fooObj1 = {
{ "bar": { "blah": 9 } },
{ "bar": { "blah": 4 } },
{ "bar": { "blah":12} }
};
So I had to modify the above code to something like below which works. Is it too too bad to be too much sticky with Object literals
var fooObj1 = {
1:{ "bar": { "blah": 9 } },
2:{ "bar": { "blah": 4 } },
3:{ "bar": { "blah":12} }
};
Thanks again and in advance to those who help me with the query.