// using the new 2019 fromEntries, this is most excelent!

const mapToObject = (map) => Object.fromEntries( Array.from( map ) );

// Usage
// Note that you should rework the above function if you have any other types as keys other than strings
// Keys in maps are unique so keep that in mind.
// Emscripten is a good use case, you cant return objects yet but you can return maps.
const example = new Map();

example.set('h','e');
example.set('l','l');
example.set('o','w');
example.set('o','r');
example.set('l','d');

const result = mapToObject(example);

// Demo perposes
console.log(result);
document.write('<pre>' + JSON.stringify(result, null, 4) + '</pre>');

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.