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)
2.1m questions
2.1m answers
60 comments
56.9k users