{"id":2457,"date":"2022-07-24T19:53:19","date_gmt":"2022-07-24T19:53:19","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=2457"},"modified":"2022-07-24T19:53:21","modified_gmt":"2022-07-24T19:53:21","slug":"javascript-map-keys","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/javascript-map-keys\/","title":{"rendered":"JavaScript Map keys() Method"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>Getting a new iterator object containing keys from the Map (keys method)<\/strong><\/p>\n<p>Now, we are going to have another method, through which, we get a new iterator object, which contains the keys for each element in the map, in their original insertion order. In short, we are going to get an iterator object, which contains the keys from the given map, in their insertion order.<\/p>\n<h2 style=\"text-align: center;\">JavaScript Map keys() Method<\/h2>\n<p>Now, let&#8217;s have a look at an example program, through which, we get an idea about the keys method. &#8211;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1788 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method.jpg\" alt=\"\" width=\"1280\" height=\"251\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method.jpg 1280w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-300x59.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-1024x201.jpg 1024w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-768x151.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/p>\n<p>If we try to have a look at the output of the above program, it comes out to be something like this &#8211;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1789 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-1.jpg\" alt=\"\" width=\"1600\" height=\"469\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-1.jpg 1600w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-1-300x88.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-1-1024x300.jpg 1024w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-1-768x225.jpg 768w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Getting-a-new-iterator-object-containing-keys-from-the-Mapkeys-method-1-1536x450.jpg 1536w\" sizes=\"auto, (max-width: 1600px) 100vw, 1600px\" \/><br \/>\nAs you can see, we got an iterator object containing all the keys for the map. Whenever you want to get the keys from the map, you can make use of the keys method. We can use this method as and when required.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Getting a new iterator object containing keys from the Map (keys method) Now, we are going to have another method, through which, we get a new iterator object, which contains the keys for each element in the map, in their original insertion order. In short, we are going to get an iterator object, which contains [&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-2457","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\/2457","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=2457"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/2457\/revisions"}],"predecessor-version":[{"id":2502,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/2457\/revisions\/2502"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=2457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=2457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=2457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}