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: 
I just tried this code, and works ...

```
var positions, users;

users = [];
positions = [
  {
    title: 'Developer',
    user: { name: 'Albert' }
  },
  {
    title: 'CEO',
    user: { name: 'Smith' }
  }
];

angular.forEach(positions, function(position) {
  users.push(position.user);
});

console.log(users);

```
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.