0

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.

1

2 Answers 2

2

use map

 userListIds: state.ddls.companyUsers.map(function (element) {
     return element.id
  });
Sign up to request clarification or add additional context in comments.

Comments

1

It does the same from @aseferov but its written in ES6:

userListIds: state.ddls.companyUsers.map(element => element.id);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.