Question: I have an array of **position** and nested **user** objects like so:

```
[ 
  position: {
    title: Developer,
    user: { name: Albert }
    },
  position: {
    title: CEO,
    user: { name: Smith }
    }
] 

```

How do I get an array of [user, user] with Angularjs?

Answer: 
Assuming this is pseudo-code (as it's missing a few `{` and `}` and you'd need variables called Developer, Albert, CEO & Smith - I've fixed these in the *working example*) you can use [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map):

```
var arr = [{ 
  Position0: {
    title: Developer,
    user: { name: Albert }
    },
 {
  Position1 : {
    title: CEO,
    user: { name: Smith }
    }
}];
var result = arr.map(function(val, idx) {
    return val["Position" + idx].user.name;
});

```

[Working Example](http://jsfiddle.net/6dfjq0ov/)
Firstly this thing does not need angularjs.

The way you can do that is using for each loop:

```
var users = [];
var positions = [{ 
  Position0: {
    title: 'Developer',
    user: { name: 'Albert' }
    },

  Position1 : {
    title: 'CEO',
    user: { name: 'Smith' }
    }
}] 
    for(var i =0; i< positions.length; i++){
        for(var j in positions[i]){ //used to loop on object properties
          if(positions[i].hasOwnProperty(j)){ //checking if the property is not inherited
             if(positions[i][j].user){ //checking if the property exist, then only will push it to array, so that array doesnot have undefined values
                users.push(positions[i][j].user);
             }
          }
        }
    }

```

users array will have the users.