I have the following array structure:
const array = [
{
id: 1,
name: "Module 1",
form:[
{field:"name"},
{field:"email"}
]
},
{
id: 2,
name: "Module 2",
form:[
{field:"name"},
{field:"address"}
]
},
{
id: 3,
name: "Module 3",
form:[
{field:"email"},
{field:"age"}
]
}
]
My challenge here is to generate a new array with all form fields so that they are not repeated. What would be the most performative and simplified way to do this with Javascript?
In the example above I need to output the following array:
const arrayResult = ["name","email","address","age"]