Languages
[Edit]
EN

JavaScript - convert Map to object

6 points
Created by:
May87
827

In this article, we would like to show you how to convert Map to object in JavaScript.

ES 10+ solution

Edit

In this example, we use Object.fromEntries() method to convert Map to object.

Note:

Object.fromEntries() method was introduced in ECMAScript 2019 (ES10).

 

Alternative solution (older JavaScript)

Edit

In this section, we present solution for older versions of JavaScript. The solution below uses forEach() to iterate over Map and save key/value pairs inside the result object.

 

See also

Edit
  1. JavaScript - convert object to Map

  2. JavaScript - convert Map to array of objects

  3. JavaScript - convert json text to dictionary (map / plain object) variable

  4. JavaScript - ECMAScript / ES versions and features

References

Edit
  1. Map - JavaScript | MDN
  2. Object.fromEntries() - JavaScript | MDN
  3. Array.prototype.forEach() - JavaScript | MDN

Alternative titles

  1. JavaScript - convert Map to JSON object
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join