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;








66















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.










share|improve this question




























    66















    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.










    share|improve this question
























      66












      66








      66


      9






      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 3 '15 at 16:47









      Jo LissJo Liss

      16k10 gold badges92 silver badges139 bronze badges




      16k10 gold badges92 silver badges139 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          139














          Use the constructor to clone Maps and Sets:



          var clonedMap = new Map(originalMap)

          var clonedSet = new Set(originalSet)





          share|improve this answer


















          • 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 a Map 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










          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
          );



          );













          draft saved

          draft discarded


















          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









          139














          Use the constructor to clone Maps and Sets:



          var clonedMap = new Map(originalMap)

          var clonedSet = new Set(originalSet)





          share|improve this answer


















          • 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 a Map 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















          139














          Use the constructor to clone Maps and Sets:



          var clonedMap = new Map(originalMap)

          var clonedSet = new Set(originalSet)





          share|improve this answer


















          • 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 a Map 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













          139












          139








          139







          Use the constructor to clone Maps and Sets:



          var clonedMap = new Map(originalMap)

          var clonedSet = new Set(originalSet)





          share|improve this answer













          Use the constructor to clone Maps and Sets:



          var clonedMap = new Map(originalMap)

          var clonedSet = new Set(originalSet)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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 a Map 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





            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 a Map 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








          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.



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현