Skip to content

Instantly share code, notes, and snippets.

@YaronMiro
Created December 5, 2021 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YaronMiro/bfb86aa8ef026a223b790f09787ce837 to your computer and use it in GitHub Desktop.
Save YaronMiro/bfb86aa8ef026a223b790f09787ce837 to your computer and use it in GitHub Desktop.
Clone JS Map - Shallow
export const cloneMapShallow = (originalMap) => {
return [...originalMap.keys()].reduce(
(cloneMap, key) => cloneMap.set(key, originalMap.get(key)),
new Map()
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment