I have, for example, the following array of objects:
data = [{id:name1, num1:12, num2:8},
{id:name2, num1:5, num2:13},
{id:name3, num1:21, num2:4}];
I am wondering, how can I refer only to property "num1" of all objects or "num2", considering, that I don't know the exact name of the property. So if I want to find the Sum of all num2 I cannot do it simply writing the following piece of code:
data.forEach(function(obj) {
Sum += obj.num2;
};
Cause "num2" may not be called "num2" but any other name, depending on the generated report (data is taken from the Microstrategy reporting system). And it is inconvenient to change the code every time just to meet the property name.
Any help is highly appreciated! :)