Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams Javascript - convert array of arrays into array of objects with prefilled values (4 answers)
Closed 2 years ago .
You can use the method suggested in this answer : arr.map(([name, age, gender]) => ({name, age, gender})); Nick Parsons Sep 5, 2020 at 15:42
var a=[ [ 'James', 23, 'male' ], [ 'Britney',45,'female']];
var result = a.map(([name,age,gender])=>({name, age, gender}));
console.log(result);