i have an array (0,…,n) and with several object. The array can be of any length.
array = {{name: alice, age: 18, hobby: dance}, {name:bob, age: 27, hobby: cars}, {name: chloe, age:45, hobby: painting}};
Now I want a new array. This new array should look like that:
new array = {alice, bob, chloe};
I can merge this objects with a for-loop. But is there a simple join or merge function which I can use?
Thanks
2
Answers
Just use
map
😉I don’t quite understand what you mean.
your origin array
array = [{name: alice, age: 18, hobby: dance}, {name:bob, age: 27, hobby: cars}, {name: chloe, age:45, hobby: painting}];
the new array you want get
new array = [alice, bob, chloe];
you can use
Is this the answer you want?