{"id":595,"date":"2023-06-20T05:08:08","date_gmt":"2023-06-20T05:08:08","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=595"},"modified":"2023-06-21T13:00:34","modified_gmt":"2023-06-21T13:00:34","slug":"difference-between-array-push-and-pop-explain-with-example","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/","title":{"rendered":"Difference between array PUSH and POP? explain with example"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png\" alt=\"\" class=\"wp-image-597\" width=\"524\" height=\"367\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png 350w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8-300x210.png 300w\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" \/><\/figure>\n\n\n\n<p>In programming, &#8220;push&#8221; and &#8220;pop&#8221; are operations commonly associated with the manipulation of data in a data structure called an array. Arrays are used to store collections of elements of the same type.<\/p>\n\n\n\n<p><strong>Push:<\/strong> The &#8220;push&#8221; operation adds an element to the end of an array, increasing its size by one. The new element is inserted at the last position, shifting any existing elements to accommodate the new one.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\nlet numbers = [1, 2, 3];\nconsole.log(numbers);  \/\/ Output: [1, 2, 3]\n\nnumbers.push(4);\nconsole.log(numbers);  \/\/ Output: [1, 2, 3, 4]\n\n\n\n<p>In this example, the <code>push<\/code> method is used to add the number 4 to the end of the <code>numbers<\/code> array. After the push operation, the array contains [1, 2, 3, 4].<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pop:<\/strong> The &#8220;pop&#8221; operation removes and returns the last element from an array, reducing its size by one. The element that is popped is permanently removed from the array.<\/li>\n<\/ul>\n\n\n\nlet numbers = [1, 2, 3, 4];\nconsole.log(numbers);  \/\/ Output: [1, 2, 3, 4]\n\nlet poppedElement = numbers.pop();\nconsole.log(numbers);           \/\/ Output: [1, 2, 3]\nconsole.log(poppedElement);     \/\/ Output: 4\n\n\n\n<p>In this example, the <code>pop<\/code> method is used to remove the last element (4) from the <code>numbers<\/code> array. The popped element is stored in the variable <code>poppedElement<\/code>. After the pop operation, the array contains [1, 2, 3], and the popped element is 4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In programming, &#8220;push&#8221; and &#8220;pop&#8221; are operations commonly associated with the manipulation of data in a data structure called an array. Arrays are used to store collections&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-595","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Difference between array PUSH and POP? explain with example - DevOps Support<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Difference between array PUSH and POP? explain with example - DevOps Support\" \/>\n<meta property=\"og:description\" content=\"In programming, &#8220;push&#8221; and &#8220;pop&#8221; are operations commonly associated with the manipulation of data in a data structure called an array. Arrays are used to store collections...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps Support\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-20T05:08:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-21T13:00:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png\" \/>\n<meta name=\"author\" content=\"Avinash kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Avinash kumar\" \/>\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:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/\"},\"author\":{\"name\":\"Avinash kumar\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347\"},\"headline\":\"Difference between array PUSH and POP? explain with example\",\"datePublished\":\"2023-06-20T05:08:08+00:00\",\"dateModified\":\"2023-06-21T13:00:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/\"},\"wordCount\":197,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/\",\"url\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/\",\"name\":\"Difference between array PUSH and POP? explain with example - DevOps Support\",\"isPartOf\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png\",\"datePublished\":\"2023-06-20T05:08:08+00:00\",\"dateModified\":\"2023-06-21T13:00:34+00:00\",\"author\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage\",\"url\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png\",\"contentUrl\":\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png\",\"width\":350,\"height\":245},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.devopssupport.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Difference between array PUSH and POP? explain with example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#website\",\"url\":\"https:\/\/www.devopssupport.in\/blog\/\",\"name\":\"DevOps Support\",\"description\":\"DevOps Support | DevSecOps Support | SRE Support | MLOps SRE Support\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.devopssupport.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347\",\"name\":\"Avinash kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g\",\"caption\":\"Avinash kumar\"},\"sameAs\":[\"www.linkedin.com\/in\/avinash-kumar-150791240\"],\"url\":\"https:\/\/www.devopssupport.in\/blog\/author\/avinash\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Difference between array PUSH and POP? explain with example - DevOps Support","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:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/","og_locale":"en_US","og_type":"article","og_title":"Difference between array PUSH and POP? explain with example - DevOps Support","og_description":"In programming, &#8220;push&#8221; and &#8220;pop&#8221; are operations commonly associated with the manipulation of data in a data structure called an array. Arrays are used to store collections...","og_url":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/","og_site_name":"DevOps Support","article_published_time":"2023-06-20T05:08:08+00:00","article_modified_time":"2023-06-21T13:00:34+00:00","og_image":[{"url":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png","type":"","width":"","height":""}],"author":"Avinash kumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Avinash kumar","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#article","isPartOf":{"@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/"},"author":{"name":"Avinash kumar","@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347"},"headline":"Difference between array PUSH and POP? explain with example","datePublished":"2023-06-20T05:08:08+00:00","dateModified":"2023-06-21T13:00:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/"},"wordCount":197,"commentCount":0,"image":{"@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/","url":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/","name":"Difference between array PUSH and POP? explain with example - DevOps Support","isPartOf":{"@id":"https:\/\/www.devopssupport.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage"},"image":{"@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png","datePublished":"2023-06-20T05:08:08+00:00","dateModified":"2023-06-21T13:00:34+00:00","author":{"@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347"},"breadcrumb":{"@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#primaryimage","url":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png","contentUrl":"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/06\/image-8.png","width":350,"height":245},{"@type":"BreadcrumbList","@id":"https:\/\/www.devopssupport.in\/blog\/difference-between-array-push-and-pop-explain-with-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.devopssupport.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Difference between array PUSH and POP? explain with example"}]},{"@type":"WebSite","@id":"https:\/\/www.devopssupport.in\/blog\/#website","url":"https:\/\/www.devopssupport.in\/blog\/","name":"DevOps Support","description":"DevOps Support | DevSecOps Support | SRE Support | MLOps SRE Support","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopssupport.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/ee29c62455ded10b2424fb9ca585e347","name":"Avinash kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopssupport.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/db01f522798b98f8f474a1dfdd200df1c0e7ada232088d7a8192e14919e4de0a?s=96&d=mm&r=g","caption":"Avinash kumar"},"sameAs":["www.linkedin.com\/in\/avinash-kumar-150791240"],"url":"https:\/\/www.devopssupport.in\/blog\/author\/avinash\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=595"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/595\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/595\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}