JavaScript map to JavaScript object

 

Object.fromEntries()

 

The Object.fromEntries() method transforms a list of key-value pairs into an object and returns an iterator object that with two-element array like objects

 

 

const exMap = new Map([
  ['one', 1],
  ['two', 2],
  ['three', 3],
  ['four', 4],
  ['five', 5],
  ['six', 6],
  ['seven', 7],
  ['eight', 8]
]);

const javaScriptObject = Object.fromEntries(exMap);

 


Tags:

Share:

Related posts