I'm reading data from a database and loading it in a array. When I print it to console I get something like this:
[
{'person.name':'name1', total:1},
{'person.name':'name2', total:100}
]
So I iterate through it with this code:
for(var i=0;i<arr.length;i++){
console.log(arr[i].total);
}
I can access the total but how can I access 'person.name'?
Try something like:
console.log(arr[i]['person.name']);
access it like an array :
arr[i]['person.name'];
Here's more info on why/when to use this notation : JavaScript property access: dot notation vs. brackets?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With