0

Say I have an array of objects:

[
  {
    'prop1': 'hello world',
    'prop2': false
  },
  {
    'prop1': 'asdf asdf',
    'prop2': true
  },
  {
    'prop1': 'bob ross',
    'prop2': false
  }
]

And now I want to create a new array that just lists one of the properties, for example:

createArrayFromProperties(array, item.prop1);

↓ Output ↓

['hello world', 'asdf asdf', 'bob ross']

Is this possible to do with a built in JS method, or do I have to use a loop?

Felix Kling
  • 756,363
  • 169
  • 1,062
  • 1,111
Alex Wohlbruck
  • 1,228
  • 2
  • 21
  • 38

0 Answers0