Reputation: 2324
I am trying to get all Ids of the company Users and add it to the int array:
userListIds: state.ddls.companyUsers.forEach(function (element) {
---How to add it to the int array
});
Thanks in advance.
Upvotes: 0
Views: 30
Reputation: 691
It does the same from @aseferov but its written in ES6:
userListIds: state.ddls.companyUsers.map(element => element.id);
Upvotes: 1
Reputation: 6393
use map
userListIds: state.ddls.companyUsers.map(function (element) {
return element.id
});
Upvotes: 2