Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

convert array to object with custom keys

const peopleArrays = [
  ['Jimbo', '555-555-5555', 'jimbo@aol.com'],
  ['Lakshmi', '123-456-7890', 'lakshmi@compuserve.com']
];

const peopleObjects = peopleArrays
  .map(([name, phone, email]) => ({ name, phone, email }));

console.log(peopleObjects);
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #convert #array #object #custom #keys
ADD COMMENT
Topic
Name
3+6 =