How do you shallow-clone a Map or Set object in JavaScript?
I want to get a new Map or Set that has the same keys and values.
Use the constructor to clone Maps and Sets:
var clonedMap = new Map(originalMap) var clonedSet = new Set(originalSet)
1.4m articles
1.4m replys
5 comments
57.0k users