Shallow-clone an ES6 Map or SetHow to shallow copy a Set in JavaScript?What is the most efficient way to deep clone an object in JavaScript?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How do I loop through or enumerate a JavaScript object?How do I correctly clone a JavaScript object?Set a default parameter value for a JavaScript functionHow can I display a JavaScript object?Convert form data to JavaScript object with jQueryParse JSON in JavaScript?Copy array by value
What can a novel do that film and TV cannot?
What is exact meaning of “ich wäre gern”?
Apex Sleep: what is CPU penalty
Is it possible that Curiosity measured its own methane or failed doing the spectrometry?
In the Seventh Seal why does Death let the chess game happen?
What happens if the limit of 4 billion files was exceeded in an ext4 partition?
Platform Event Design when Subscribers are Apex Triggers
Are "confidant" and "confident" homophones?
Contributing to a candidate as a Foreign National US Resident?
Why did moving the mouse cursor cause Windows 95 to run more quickly?
What is the fundamental difference between catching whales and hunting other animals?
Did Snape really give Umbridge a fake Veritaserum potion that Harry later pretended to drink?
how can i make this execution plan more efficient?
Implementing absolute value function in c
How to deal with administrative duties killing the research spirit?
How to travel between two stationary worlds in the least amount of time? (time dilation)
What is the difference between a historical drama and a period drama?
What are the differences of checking a self-signed certificate vs ignore it?
Does a multiclassed wizard start with a spellbook?
What is this arch-and-tower near a road?
Do I need to be legally qualified to install a Hive smart thermostat?
How to deal with a Murder Hobo Paladin?
List comprehensions in Mathematica?
Show that there are infinitely more problems than we will ever be able to compute
Shallow-clone an ES6 Map or Set
How to shallow copy a Set in JavaScript?What is the most efficient way to deep clone an object in JavaScript?Setting “checked” for a checkbox with jQuery?How can I know which radio button is selected via jQuery?How do I loop through or enumerate a JavaScript object?How do I correctly clone a JavaScript object?Set a default parameter value for a JavaScript functionHow can I display a JavaScript object?Convert form data to JavaScript object with jQueryParse JSON in JavaScript?Copy array by value
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How do you shallow-clone an ES6 Map or Set object?
I want to get a new Map or Set that has the same keys and values.
javascript ecmascript-6
add a comment |
How do you shallow-clone an ES6 Map or Set object?
I want to get a new Map or Set that has the same keys and values.
javascript ecmascript-6
add a comment |
How do you shallow-clone an ES6 Map or Set object?
I want to get a new Map or Set that has the same keys and values.
javascript ecmascript-6
How do you shallow-clone an ES6 Map or Set object?
I want to get a new Map or Set that has the same keys and values.
javascript ecmascript-6
javascript ecmascript-6
asked Jun 3 '15 at 16:47
Jo LissJo Liss
16k10 gold badges92 silver badges139 bronze badges
16k10 gold badges92 silver badges139 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Use the constructor to clone Maps and Sets:
var clonedMap = new Map(originalMap)
var clonedSet = new Set(originalSet)
1
How to do a deep clone?
– BILL
Apr 29 '16 at 11:34
3
Check out this fiddle to see how to deep clone a map: jsfiddle.net/pahund/5qtt2Len/1
– Patrick Hund
Feb 24 '17 at 13:23
3
Map
should be treated as an abstract data type, not as a Javascript object. Hence deep cloning aMap
doesn't make sense.
– user6445533
Feb 25 '17 at 20:55
3
Unfortunately the copy constructor does not work in IE 11 (empty map is created).
– Jan Molnar
Jan 17 '18 at 12:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30626070%2fshallow-clone-an-es6-map-or-set%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use the constructor to clone Maps and Sets:
var clonedMap = new Map(originalMap)
var clonedSet = new Set(originalSet)
1
How to do a deep clone?
– BILL
Apr 29 '16 at 11:34
3
Check out this fiddle to see how to deep clone a map: jsfiddle.net/pahund/5qtt2Len/1
– Patrick Hund
Feb 24 '17 at 13:23
3
Map
should be treated as an abstract data type, not as a Javascript object. Hence deep cloning aMap
doesn't make sense.
– user6445533
Feb 25 '17 at 20:55
3
Unfortunately the copy constructor does not work in IE 11 (empty map is created).
– Jan Molnar
Jan 17 '18 at 12:10
add a comment |
Use the constructor to clone Maps and Sets:
var clonedMap = new Map(originalMap)
var clonedSet = new Set(originalSet)
1
How to do a deep clone?
– BILL
Apr 29 '16 at 11:34
3
Check out this fiddle to see how to deep clone a map: jsfiddle.net/pahund/5qtt2Len/1
– Patrick Hund
Feb 24 '17 at 13:23
3
Map
should be treated as an abstract data type, not as a Javascript object. Hence deep cloning aMap
doesn't make sense.
– user6445533
Feb 25 '17 at 20:55
3
Unfortunately the copy constructor does not work in IE 11 (empty map is created).
– Jan Molnar
Jan 17 '18 at 12:10
add a comment |
Use the constructor to clone Maps and Sets:
var clonedMap = new Map(originalMap)
var clonedSet = new Set(originalSet)
Use the constructor to clone Maps and Sets:
var clonedMap = new Map(originalMap)
var clonedSet = new Set(originalSet)
answered Jun 3 '15 at 16:47
Jo LissJo Liss
16k10 gold badges92 silver badges139 bronze badges
16k10 gold badges92 silver badges139 bronze badges
1
How to do a deep clone?
– BILL
Apr 29 '16 at 11:34
3
Check out this fiddle to see how to deep clone a map: jsfiddle.net/pahund/5qtt2Len/1
– Patrick Hund
Feb 24 '17 at 13:23
3
Map
should be treated as an abstract data type, not as a Javascript object. Hence deep cloning aMap
doesn't make sense.
– user6445533
Feb 25 '17 at 20:55
3
Unfortunately the copy constructor does not work in IE 11 (empty map is created).
– Jan Molnar
Jan 17 '18 at 12:10
add a comment |
1
How to do a deep clone?
– BILL
Apr 29 '16 at 11:34
3
Check out this fiddle to see how to deep clone a map: jsfiddle.net/pahund/5qtt2Len/1
– Patrick Hund
Feb 24 '17 at 13:23
3
Map
should be treated as an abstract data type, not as a Javascript object. Hence deep cloning aMap
doesn't make sense.
– user6445533
Feb 25 '17 at 20:55
3
Unfortunately the copy constructor does not work in IE 11 (empty map is created).
– Jan Molnar
Jan 17 '18 at 12:10
1
1
How to do a deep clone?
– BILL
Apr 29 '16 at 11:34
How to do a deep clone?
– BILL
Apr 29 '16 at 11:34
3
3
Check out this fiddle to see how to deep clone a map: jsfiddle.net/pahund/5qtt2Len/1
– Patrick Hund
Feb 24 '17 at 13:23
Check out this fiddle to see how to deep clone a map: jsfiddle.net/pahund/5qtt2Len/1
– Patrick Hund
Feb 24 '17 at 13:23
3
3
Map
should be treated as an abstract data type, not as a Javascript object. Hence deep cloning a Map
doesn't make sense.– user6445533
Feb 25 '17 at 20:55
Map
should be treated as an abstract data type, not as a Javascript object. Hence deep cloning a Map
doesn't make sense.– user6445533
Feb 25 '17 at 20:55
3
3
Unfortunately the copy constructor does not work in IE 11 (empty map is created).
– Jan Molnar
Jan 17 '18 at 12:10
Unfortunately the copy constructor does not work in IE 11 (empty map is created).
– Jan Molnar
Jan 17 '18 at 12:10
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30626070%2fshallow-clone-an-es6-map-or-set%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown