Convert Map to object

Angelos Chalaris · JavaScript, Object · Jun 16, 2022

Converts a Map to an object.

const mapToObject = map => Object.fromEntries(map.entries());
mapToObject(new Map([['a', 1], ['b', 2]])); // {a: 1, b: 2}

Recommended snippets