{"id":2459,"date":"2022-07-24T19:44:35","date_gmt":"2022-07-24T19:44:35","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=2459"},"modified":"2022-07-24T19:44:37","modified_gmt":"2022-07-24T19:44:37","slug":"javascript-map-get","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/javascript-map-get\/","title":{"rendered":"JavaScript Map get() Method"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>Getting the value associated with the key(get method)<\/strong><\/p>\n<p>Now, we have the key-value pairs on the Map, and now we are going to concentrate on how can we get the value associated with the key from the Map. We got a method for this, which is the get method. With this method, we just have to specify for what key, do we need the value? Means value associated with which key, that key needs to be passed here, and then we are going to get the value of the corresponding key &#8211;<\/p>\n<h3 class=\"LC20lb MBeuO DKV0Md\" style=\"text-align: center;\">JavaScript Map get Method<\/h3>\n<p>Let&#8217;s have a look at a simple example, through which, we can understand the get method here.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1784 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method.jpg\" alt=\"\" width=\"1301\" height=\"330\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method.jpg 1301w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-300x76.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-1024x260.jpg 1024w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-768x195.jpg 768w\" sizes=\"auto, (max-width: 1301px) 100vw, 1301px\" \/><\/p>\n<p>As you can see, we want to get the value associated with key 1. So, the output that we get, is JavaScript(which is the corresponding\u00a0value). Have a look at the output now &#8211;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1785 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-1.jpg\" alt=\"\" width=\"1600\" height=\"251\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-1.jpg 1600w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-1-300x47.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-1-1024x161.jpg 1024w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-1-768x120.jpg 768w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-the-value-associated-to-the-keyget-method-1-1536x241.jpg 1536w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><\/p>\n<p>As you can see, we got the value corresponding to key 1, which is JavaScript. You can also try some other keys here, with the get method.<\/p>\n<p>Now, what if we give such a key, which is not present on the Map? Well, you can try doing this. It is going to give undefined in such a case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting the value associated with the key(get method) Now, we have the key-value pairs on the Map, and now we are going to concentrate on how can we get the value associated with the key from the Map. We got a method for this, which is the get method. With this method, we just have [&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-2459","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\/2459","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=2459"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/2459\/revisions"}],"predecessor-version":[{"id":2500,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/2459\/revisions\/2500"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=2459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=2459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=2459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}