{"id":2468,"date":"2022-07-24T19:30:50","date_gmt":"2022-07-24T19:30:50","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=2468"},"modified":"2022-07-24T19:30:52","modified_gmt":"2022-07-24T19:30:52","slug":"javascript-map-set","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/javascript-map-set\/","title":{"rendered":"JavaScript Map set() Method"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>Setting the key-value pairs in the Map (set method)<\/strong><\/p>\n<p>Now, we know how to create the Map object, and we have created one, but how about adding some key-value pairs to the Map? Well, we can do this, using the set method.<\/p>\n<p>Let&#8217;s have a look at the program now, through which, we are going to understand using the set method. You will be able to see that we are passing two values to the set method.<\/p>\n<h3 style=\"text-align: center;\">JavaScript Map Set<\/h3>\n<p>Here, the first value is the key, and the other value is the value. Let&#8217;s have a look at the program now &#8211;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1780 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method.jpg\" alt=\"\" width=\"1293\" height=\"333\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method.jpg 1293w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-300x77.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-1024x264.jpg 1024w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-768x198.jpg 768w\" sizes=\"auto, (max-width: 1293px) 100vw, 1293px\" \/><\/p>\n<p>You can observe in the above program, that we have created the Map object, and then we are using the set method, to have some key-value pairs in the Map. We are passing two values to the set method, and the first one is the key, and the other one is the value. In the end, we are trying to print the Map object. Let&#8217;s have a look at the output now &#8211;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1781 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-1.jpg\" alt=\"\" width=\"1600\" height=\"476\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-1.jpg 1600w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-1-300x89.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-1-1024x305.jpg 1024w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-1-768x228.jpg 768w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Setting-the-key-value-pairs-in-the-Mapset-method-1-1536x457.jpg 1536w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>As you can see, we got the Map object with some key-value pairs here. This was easy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting the key-value pairs in the Map (set method) Now, we know how to create the Map object, and we have created one, but how about adding some key-value pairs to the Map? Well, we can do this, using the set method. Let&#8217;s have a look at the program now, through which, we are going [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14,15],"class_list":{"0":"post-2468","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-javascript-tutorial","7":"tag-javascript","8":"tag-javascript-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/2468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=2468"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/2468\/revisions"}],"predecessor-version":[{"id":2499,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/2468\/revisions\/2499"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=2468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=2468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=2468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}