0

I’ve the following object which needs to get and array of values

 const myVal: QuickPickItem[] = [data.result.eventDefinitions.data]

The array should get items like [ “a1”,”a2”,”a3”]

The data.result.eventDefinitions.data is array of objects,

data.result.eventDefinitions.data = 
{
name:”aaaa”
desc:”test”

},
{
name:”bbbb”
desc:”test2”

}

How should I pass the values of names to myVal to be an array like

[ “aaaa”,bbbb”] , should I use lodash?

0

2 Answers 2

2

That can be done with the native array.map()

Just pass the items to map than have it return the value of name and you will end up with the array you specified.

let newArray = data.result.eventDefinitions.data.map(item => item.name)

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

Comments

1

data.result.eventDefinitions.data.map(el => el.name)

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.