What is the most efficient method for creating sub-arrays from an array? I have an array of objects like this:
bigArray = [
{
id: 1,
name: "Marc",
age: 29
},
{
id: 2,
name: "Caroline",
age: 27
},
{
id: 3,
name: "John",
age: 30
}];
I want to generate 3 sub-arrays:
- ids = [1, 2, 3]
- names = ["Marc", "Caroline", "John"]
- ages = [29, 27, 30]
I've attempted using nested "for" loops and experimented with the map() method, but I'm not convinced it's the most efficient way. Especially since each object may have multiple parameters (such as last name, city, car...)