Question: I wasnt quite sure what to call this question but here is what i want to do:

I am currently creating a series geneator for `chartjs` that will help me create my datasets.

now the way i want to do it is by simply using `object keys` to extract data from each element in my array.

Each element of an array could look something like this:

[![enter image description here](https://i.stack.imgur.com/IXl3D.png)](https://i.stack.imgur.com/IXl3D.png)

as you can see this object contains other objects inside of them. 

This creates a problem because say i want the name of the object `feedback_skill` i would have to do the following:

```
            data.forEach(function (x) {
             x['feedback_skill']['name']
        });

```

Which cannot be hold into one variable.

Now what i could do is pass the following array: `serieKey = ['feedback','name']` suggesting that the first element in the array is the first key and the next element is the variable i want to hit.

However these datasets can have an unlimited number of layers so my question to you guys is:

Is there a smart way of doing this?

Answer: 
I'm not aware of a native JavaScript way of doing this, but various JavaScript frameworks allow you to access deep-properties from objects like this. For example Dojo has [lang.getObject](https://dojotoolkit.org/reference-guide/1.10/dojo/_base/lang.html#dojo-base-lang-getobject) and I can see that there is a [JQuery plugin](http://benalman.com/projects/jquery-getobject-plugin/) that does something similar, lodash [as well](https://lodash.com/docs#get). If you're not using these frameworks, then you could always create your own util function to perform something similar.

These types of utility function allow you to pass the target as a "dot-notation" property, so you could call:

```
lang.getObject("feedback_skill.name", false, x)

```

Using Dojo for example, but they're all much of a muchness.
I don't see any problem with your approach, unlimited number of layers can be handled in the following manner :

```
data.forEach(function(x){
    for(i in seriesKey)
        x = x[seriesKey[i]]; // x will contain whatever you wanted to retrieve when the loop ends
    doSomething(x);
}

```

seriesKey can be an array like the one in your example, with as many elements as you need to traverse to the depth you want.