JSFiddle - React, Tailwind, and code Playground

JavaScript

const m1 = new Map();
const obj = { prop: 'value' };
m1.set('obj', obj);
dumpMap('m1 contains', m1);

// create a shallow clone of m1
const m2 = new Map(m1);
dumpMap('m2 contains', m2);

console.log('altering a property inside the m2 map');
m2.get('obj').prop = 'new-value';

dumpMap('m1 now contains', m1);
dumpMap('m2 now contains', m2);

// We need to convert the Map to a string, because chrome's web inspector doesn't
// traverse the object. It'll only do that when you interact with the object in the console.
// At that time the rest of the code will have run already and you'll only see the latest
// version of the object.
function dumpMap(str, m) {
	console.log(str, JSON.stringify(m, (key, value) => (value instanceof Map ? [...value] : value)));
}