var clonedMap = new Map(originalMap)
var clonedSet = new Set(originalSet)
深度克隆:
var deepClonedMap = new Map(JSON.parse(JSON.stringify([...originalMap])))
var deepClonedSet = new Set(JSON.parse(JSON.stringify([...originalSet])))
let originalMap = new Map()
let data = {a:'a',b:'b'}
originalMap.set(1,data)
let shallowCloned = new Map(originalMap)
let deepCloned = new Map(JSON.parse(JSON.stringify([...originalMap])))
data.a = 'p'
console.log('originalMap:',[...originalMap])
console.log('shallowCloned:',[...shallowCloned])
console.log('deepCloned:',[...deepCloned])