{"id":19345,"date":"2020-07-11T11:02:47","date_gmt":"2020-07-11T18:02:47","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=19345"},"modified":"2020-12-29T13:42:43","modified_gmt":"2020-12-29T21:42:43","slug":"javascript-pop","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/javascript-pop\/","title":{"rendered":"JavaScript Pop Method: What Is It and How to Use It"},"content":{"rendered":"\n<p><em>The JavaScript array pop method called is one of several array methods that can be used to manipulate data in arrays. Web developers use it in times when they need to do something either with the shortened array or with the popped element. Let\u2019s learn how to use it:&nbsp;<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<p>The syntax for this method is fairly straightforward. By definition, the pop method removes the last element in an array and then returns it:&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>let frozen = [ &quot;Anna&quot;, &quot;Elsa&quot;, &quot;Olaf&quot;, &quot;Kristoff&quot;, &quot;Sven&quot; ];\nlet popped = frozen.pop();<\/pre><\/div>\n\n\n\n<p>If you were to type this code into the web browser console (*see side note below if you don\u2019t know how to do that), and <code>console.log<\/code> (frozen) and <code>console.log<\/code> (popped), what would happen?&nbsp;<br><\/p>\n\n\n\n<p>Frozen would come back as an array with one less element and popped would be the element that was removed from the array:&nbsp;<br><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"607\" src=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/Screen-Shot-2020-07-09-at-8.55.57-AM.jpg\" alt=\"Chrome Developer Console demonstrates how the pop method works\" class=\"wp-image-19347\" srcset=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/Screen-Shot-2020-07-09-at-8.55.57-AM.jpg 1020w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/Screen-Shot-2020-07-09-at-8.55.57-AM-768x457.png 768w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/Screen-Shot-2020-07-09-at-8.55.57-AM-770x458.png 770w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/Screen-Shot-2020-07-09-at-8.55.57-AM-385x229.png 385w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/Screen-Shot-2020-07-09-at-8.55.57-AM-20x12.jpg 20w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><figcaption> The Chrome Developer Console demonstrates how the pop method works in JavaScript:&nbsp; Everytime pop() is used, frozen comes back with one less element and the popped element comes back as the removed item.&nbsp; <\/figcaption><\/figure>\n\n\n\n<p><strong>* Side Note:&nbsp; How to Access JavaScript Console in Chrome\/Firefox\/Safari:<\/strong><br><\/p>\n\n\n\n<p><strong>Chrome\/Firefox:<\/strong> In Chrome, right click on this page, select \u2018Inspect\u2019. You\u2019ll see the Chrome Developer Tools pop open. At the top there should be a set of navigable tabs. Firefox is similar, but you will select \u2018Inspect Element\u2019. Click on Console and your workspace will be there.&nbsp; <br><br><strong>Safari: <\/strong>&nbsp;If you use Safari, you will need to enable the \u2018Developer\u2019 menu. To do so, open the <strong>Safari<\/strong> browser, click on <strong>Safari<\/strong> and then go to \u2018Preferences\u2019. Click on \u2018Advanced\u2019. Check the \u2018Show Develop menu in menu bar\u2019 checkbox. Close the \u2018Preferences\u2019 and then click on \u2018Develop\u2019 in the menu bar. Select \u2018Show JavaScript Console\u2019.&nbsp;<br><\/p>\n\n\n\n<p>You should now be able to type in the information in the example above (or come up with your own example!). Once both frozen and popped variables have been created, console.log both to see the effects the code has on the elements.&nbsp;&nbsp;<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>The pop method changes the length of the array. You can use it for as long as the length of the array exists. When there is an empty array, the method can still be performed (as in it won\u2019t throw an error or anything), but the popped element will return \u2018undefined\u2019.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The pop array method opens up opportunities to use it in logic where we need to remove the last item from an array and then do something with it. This is the opposite of the push method, which adds something to the end of the array and is comparable to the shift method, which removes an element from the front of the array and returns that element.<\/p>\n","protected":false},"excerpt":{"rendered":"The JavaScript array pop method called is one of several array methods that can be used to manipulate data in arrays. Web developers use it in times when they need to do something either with the shortened array or with the popped element. Let\u2019s learn how to use it:&nbsp; Syntax The syntax for this method&hellip;","protected":false},"author":77,"featured_media":19346,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11933],"tags":[],"class_list":{"0":"post-19345","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"JavaScript","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>JavaScript Pop Method: What Is It and How to Use It | Career Karma<\/title>\n<meta name=\"description\" content=\"As JavaScript developers, we have several tools available to help us do what we need to do. The pop method is one of several array methods that we can use to help our logic. This tutorial shows how to use it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/javascript-pop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Pop Method: What Is It and How to Use It\" \/>\n<meta property=\"og:description\" content=\"As JavaScript developers, we have several tools available to help us do what we need to do. The pop method is one of several array methods that we can use to help our logic. This tutorial shows how to use it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/javascript-pop\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-11T18:02:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-29T21:42:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"680\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Christina Kopecky\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christina Kopecky\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/\"},\"author\":{\"name\":\"Christina Kopecky\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e\"},\"headline\":\"JavaScript Pop Method: What Is It and How to Use It\",\"datePublished\":\"2020-07-11T18:02:47+00:00\",\"dateModified\":\"2020-12-29T21:42:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/\"},\"wordCount\":465,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/\",\"name\":\"JavaScript Pop Method: What Is It and How to Use It | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg\",\"datePublished\":\"2020-07-11T18:02:47+00:00\",\"dateModified\":\"2020-12-29T21:42:43+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e\"},\"description\":\"As JavaScript developers, we have several tools available to help us do what we need to do. The pop method is one of several array methods that we can use to help our logic. This tutorial shows how to use it.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/javascript-pop\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg\",\"width\":1020,\"height\":680},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/javascript-pop\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/careerkarma.com\/blog\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript Pop Method: What Is It and How to Use It\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e\",\"name\":\"Christina Kopecky\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg\",\"caption\":\"Christina Kopecky\"},\"description\":\"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.\",\"sameAs\":[\"http:\/\/www.linkedin.com\/in\/cmvnk\"],\"url\":\"https:\/\/careerkarma.com\/blog\/author\/christina-kopecky\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"JavaScript Pop Method: What Is It and How to Use It | Career Karma","description":"As JavaScript developers, we have several tools available to help us do what we need to do. The pop method is one of several array methods that we can use to help our logic. This tutorial shows how to use it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/javascript-pop\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Pop Method: What Is It and How to Use It","og_description":"As JavaScript developers, we have several tools available to help us do what we need to do. The pop method is one of several array methods that we can use to help our logic. This tutorial shows how to use it.","og_url":"https:\/\/careerkarma.com\/blog\/javascript-pop\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-11T18:02:47+00:00","article_modified_time":"2020-12-29T21:42:43+00:00","og_image":[{"width":1020,"height":680,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg","type":"image\/jpeg"}],"author":"Christina Kopecky","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Christina Kopecky","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/"},"author":{"name":"Christina Kopecky","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"headline":"JavaScript Pop Method: What Is It and How to Use It","datePublished":"2020-07-11T18:02:47+00:00","dateModified":"2020-12-29T21:42:43+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/"},"wordCount":465,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/javascript-pop\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/","url":"https:\/\/careerkarma.com\/blog\/javascript-pop\/","name":"JavaScript Pop Method: What Is It and How to Use It | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg","datePublished":"2020-07-11T18:02:47+00:00","dateModified":"2020-12-29T21:42:43+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e"},"description":"As JavaScript developers, we have several tools available to help us do what we need to do. The pop method is one of several array methods that we can use to help our logic. This tutorial shows how to use it.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/javascript-pop\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/fringer-cat-av7NMiwUWhk-unsplash.jpg","width":1020,"height":680},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/javascript-pop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/careerkarma.com\/blog\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Pop Method: What Is It and How to Use It"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/ae0cdc4a5d198690d78482646894074e","name":"Christina Kopecky","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/06\/image-3-150x150.jpg","caption":"Christina Kopecky"},"description":"Christina is an experienced technical writer, covering topics as diverse as Java, SQL, Python, and web development. She earned her Master of Music in flute performance from the University of Kansas and a bachelor's degree in music with minors in French and mass communication from Southeast Missouri State. Prior to joining the Career Karma team in June 2020, Christina was a teaching assistant, team lead, and section lead at Lambda School, where she led student groups, performed code and project reviews, and debugged problems for students. Christina's technical content is featured frequently in publications like Codecademy, Repl.it, and Educative.","sameAs":["http:\/\/www.linkedin.com\/in\/cmvnk"],"url":"https:\/\/careerkarma.com\/blog\/author\/christina-kopecky\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=19345"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19345\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19346"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=19345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=19345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=19345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}