0

Here is what I try to convert:

[{"id":4,"name":"Group4"},{"id":6,"name":"Group6"}]

So I want to convert it into single JavaScript array like:

[4,6]
2
  • may be: arr = arr.map(function(el){ return el.id; }); Commented Oct 24, 2015 at 19:49
  • Are you asking if there is a built in angular way to do this? Or are you looking for a JavaScript solution? Commented Oct 24, 2015 at 19:51

1 Answer 1

3

Use map: inputArray.map(function (element) { return element.id; });

Sign up to request clarification or add additional context in comments.

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.