1

I have array, which contains arrays of objects from different tables. How can I get all names of all these objects in array of arrays? I know, they are weirdly nested, but that's how structure is for now. enter image description here

1
  • Recursive (if needed) loop! Commented Apr 29, 2021 at 9:36

2 Answers 2

1

Just write:

const getNames = (data) => data.flat().map(({name})=> name)

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

Comments

0

use a nested for loop on the array

var names = []
for (let i = 0 ; i < array.length ; i++){
    for(let j = 0 ; j<array[i].length; j ++){
        names.push(array[i][j].name)
    }
}
console.log(names)

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.