How to convert 2D array to object in TypeScript

1 Answer

0 votes
const arr = [
  ['name', 'Rog'],
  ['age', 45],
  ['lang', 'typescript'],
];

const obj = Object.fromEntries(arr);

console.log(obj);

  
  
  
  
/*
run:
  
{
  "name": "Rog",
  "age": 45,
  "lang": "typescript"
} 
  
*/

 



answered May 23, 2022 by avibootz

Related questions

1 answer 105 views
1 answer 124 views
3 answers 214 views
1 answer 199 views
1 answer 149 views
...