Tips

Map From-To Object

Map to Object

const map = new Map([
  ['name', 'Alice'],
  ['age', 25]
]);
 
const obj = Object.fromEntries(map);
console.log(obj); // { name: 'Alice', age: 25 }

Object to Map

const obj = {
  name: 'Alice',
  age: '25'
};
 
const map = new Map(Object.entries(obj));
console.log(map); // Map(2) {'name' => 'Alice', 'age' => '25'}
Last Update: 04:05 - 25 April 2024

On this page