Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

convert array to object with custom keys

const yourArray = ['Jimbo', '555-555-5555', 'jimbo@aol.com'];

const [name, phone, email] = yourArray;
const yourObject = { name, phone, email };

console.log(yourObject);
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: Getting Error “cannot read property split of null” 
Javascript :: search with multiple field in node js mongodb 
Javascript :: unregister react hook form 
Javascript :: how to pass callback function in javascript 
Javascript :: checked unchecked through js 
Javascript :: node js postgresql query 
Javascript :: how to do if condition in kedo column in angular 
Javascript :: find element causing vertical overflow 
Javascript :: toggle button in angularjs bootstrap 
Javascript :: create multiple array buttons in javascript 
Javascript :: express proxy 
Javascript :: react usestate 
Javascript :: find second smallest number in array javascript using for loop 
Javascript :: google scripts urlfetchapp hearders and body 
Javascript :: vb net textbox regular expression 
Javascript :: get the authors username discord.js 
Javascript :: how to add a message sound in angular 
Javascript :: document ready vanilla js 
Javascript :: mongoose auto increment 
Javascript :: selialize jquery 
Javascript :: react-datepicker float position 
Javascript :: scss in react app 
Javascript :: shorthand if in javascript with return 
Javascript :: react axios Card List 
Javascript :: Get position of each element using jquery 
Javascript :: random email js 
Javascript :: moment min 
Javascript :: Play Audio Stream from Client 
Javascript :: javascript variable as object key 
Javascript :: picture in picture remove from videojs 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =