codesnippetjavascript

Object to Map

const o = { a: 1, b: 'two' }
const m = new Map(Object.entries(o))

Map to Object

const m = new Map([
  ['a', 1],
  ['b', 'two']
])
const o = Object.fromEntries(m)