{"id":8110,"date":"2025-05-08T05:21:40","date_gmt":"2025-05-08T05:21:40","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=8110"},"modified":"2025-09-04T05:07:36","modified_gmt":"2025-09-04T05:07:36","slug":"how-to-append-items-to-js-array","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/","title":{"rendered":"How to Append Items to JS Array"},"content":{"rendered":"\n<p>Web developers commonly use JavaScript arrays to store and manipulate data. JS arrays are easy to use and offer tons of functions to do many different things with them. Sometimes, web developers need to <a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-add-new-elements-to-beginning-of-array-in-javascript\/\">add items to beginning of array<\/a>. Sometimes, they need to append items to JS array. This is commonly required in <a href=\"https:\/\/ubiq.co\/dashboard-reporting-software-tool\">data analytics and reporting<\/a>. There are several simple ways to do this. In this article, we will learn how to append items to JS array.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#How_to_Append_Items_to_JS_Array\" >How to Append Items to JS Array<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#1_Using_push\" >1. Using push()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#2_Using_concat\" >2. Using concat()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#3_Using_spread_operator\" >3. Using spread operator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#4_Using_unshift\" >4. Using unshift()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#5_Using_length_property\" >5. Using length property<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Append_Items_to_JS_Array\"><\/span>How to Append Items to JS Array<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the different ways to add items to JS array.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_push\"><\/span>1. Using push()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Every JS array supports push() function that allows you to append one or more items to the array. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">array.push(item1, item2, ...)<\/pre>\n\n\n\n<p>Here is an example to push one item to an array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a = [1, 2, 3]<br>a.push(4)<br>console.log(a) \/\/ [1, 2, 3, 4]<\/pre>\n\n\n\n<p>Here is an example to push multiple items to an array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a = [1, 2, 3]<br>a.push(4, 5)<br>console.log(a) \/\/ [1, 2, 3, 4, 5]<\/pre>\n\n\n\n<p>This method will alter the original array after appending new item.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_concat\"><\/span>2. Using concat()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The above solution is useful when you want to add separate items to an array. If you want to add items of one array to another array then you can use concat() function. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">array1.concat(array2)<\/pre>\n\n\n\n<p>Here is an example to add items of one array to another, using concat() function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a1 = [1, 2, 3];<br>a2 = [4, 5, 6];<br>a1=a1.concat(a2)<br>console.log(a1) \/\/ [1, 2, 3, 4, 5, 6]<\/pre>\n\n\n\n<p>It is very important to determine the array for which you call concat() function and the array that is passed as the argument. Please note what happens when you swap the two arrays in concat() function call.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a1 = [1, 2, 3];<br>a2 = [4, 5, 6];<br>a2=a2.concat(a1)<br>console.log(a2) \/\/ [ 4, 5, 6, 1, 2, 3 ]<\/pre>\n\n\n\n<p>As you can see above, the output in above two cases is completely different. So the order of concatenation is very important.<\/p>\n\n\n\n<p>Also, if you have common items in the two array, the result will contain each copy of the common item.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a1 = [1, 2, 3];<br>a2 = [3, 4, 5];<br>a1=a1.concat(a2)<br>console.log(a1) \/\/ [1, 2, 3, 3, 4, 5]<\/pre>\n\n\n\n<p>In the above example, you will see that both arrays a1 and a2 contain item &#8216;3&#8217;. So the result contains two copies of item &#8216;3&#8217;.<\/p>\n\n\n\n<p>You can also chain concat() functions one after the other to append items from multiple arrays into a single array. Here is an example to demonstrate it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a1 = [1, 2, 3];<br>a2 = [4, 5, 6];<br>a3 = [7, 8, 9];<br>a1=a1.concat(a2).concat(a3)<br>console.log(a1) \/\/ [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]<\/pre>\n\n\n\n<p>Please note, the concat() returns a new array after concatenation and does not alter any of the original arrays used for concatenation. So if you want to append items of one array to another, then you need to re-assign the result of concatenation to either of the arrays.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_spread_operator\"><\/span>3. Using spread operator<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can also use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/Spread_syntax\" target=\"_blank\" rel=\"noreferrer noopener\">spread operator<\/a> &#8216;&#8230;&#8217; to concatenate items of one array to another. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[...array1, ...array2, ...]<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">a1 = [1, 2, 3];<br>a2 = [4, 5, 6];<br>a3 = [7, 8, 9];<br>a1=[...a1,...a2]<br>console.log(a1) \/\/ [1, 2, 3, 4, 5, 6]<\/pre>\n\n\n\n<p>You can use spread operator to append items from multiple arrays to an array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a1 = [1, 2, 3];<br>a2 = [4, 5, 6];<br>a3 = [7, 8, 9];<br>a1 = [...a1,...a2,...a3]<br>console.log(a1) \/\/ [1, 2, 3, 4, 5, 6, 7, 8, 9]<\/pre>\n\n\n\n<p>Like concat() method, spread operator also returns a new array containing the result, instead of modifying any of the original arrays. So you will need to assign the result to one of the original arrays, in order to alter it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Using_unshift\"><\/span>4. Using unshift()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you want to prepend an item, to the beginning of an array, instead of appending it to the end, then you can use unshift() method.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">array.unshift(item)<\/pre>\n\n\n\n<p>Here is an example to append item &#8216;0&#8217; to an array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">var a = [1, 2, 3];<br>a.unshift(0);<br>console.log(a); \/\/ [ 0, 1, 2, 3 ]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Using_length_property\"><\/span>5. Using length property<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can also use the length property of the array as an index value to append an item to the array.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">array[array.length] = item<\/pre>\n\n\n\n<p>Here is an example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a1 = [1, 2, 3];<br>a1[a1.length]=4;<br>console.log(a1) \/\/ [1, 2, 3, 4]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt several simple ways to easily append items to JS array. We learnt how to add items using push(), concat() and unshift() methods. We also learnt how to do it using spread operator and length property. For small arrays, using length property is a faster way to append items to an array. On the other hand, for large arrays, using push() method is the faster way to append items. You can use any of these solutions as per your requirement.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-check-if-string-is-valid-number\/\">How to Check if String is a Valid Number<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-get-difference-between-two-arrays-in-javascript\/\">How to Get Difference Between Two Arrays<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-character-from-string-in-javascript\/\">How to Remove Character from String in JavaScript<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Often web developers need to append items to JS array. Here are different ways to add items to JS array.<\/p>\n","protected":false},"author":1,"featured_media":8127,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[295],"tags":[420],"class_list":["post-8110","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-array-append"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Append Items to JS Array - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Often web developers need to append items to JS array. Here are different ways to add items to JS array.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Append Items to JS Array - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Often web developers need to append items to JS array. Here are different ways to add items to JS array.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-08T05:21:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-04T05:07:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/05\/append-items-to-js-array.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"288\" \/>\n\t<meta property=\"og:image:height\" content=\"192\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Append Items to JS Array\",\"datePublished\":\"2025-05-08T05:21:40+00:00\",\"dateModified\":\"2025-09-04T05:07:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/\"},\"wordCount\":653,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1\",\"keywords\":[\"array append\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/\",\"name\":\"How to Append Items to JS Array - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1\",\"datePublished\":\"2025-05-08T05:21:40+00:00\",\"dateModified\":\"2025-09-04T05:07:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Often web developers need to append items to JS array. Here are different ways to add items to JS array.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/05\\\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1\",\"width\":288,\"height\":192,\"caption\":\"append items to js array\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-append-items-to-js-array\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Append Items to JS Array\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Append Items to JS Array - Ubiq BI","description":"Often web developers need to append items to JS array. Here are different ways to add items to JS array.","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:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/","og_locale":"en_US","og_type":"article","og_title":"How to Append Items to JS Array - Ubiq BI","og_description":"Often web developers need to append items to JS array. Here are different ways to add items to JS array.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-05-08T05:21:40+00:00","article_modified_time":"2025-09-04T05:07:36+00:00","og_image":[{"width":288,"height":192,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/05\/append-items-to-js-array.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Append Items to JS Array","datePublished":"2025-05-08T05:21:40+00:00","dateModified":"2025-09-04T05:07:36+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/"},"wordCount":653,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/05\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1","keywords":["array append"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/","name":"How to Append Items to JS Array - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/05\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1","datePublished":"2025-05-08T05:21:40+00:00","dateModified":"2025-09-04T05:07:36+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Often web developers need to append items to JS array. Here are different ways to add items to JS array.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/05\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/05\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1","width":288,"height":192,"caption":"append items to js array"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-append-items-to-js-array\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Append Items to JS Array"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/05\/append-items-to-js-array.jpg?fit=288%2C192&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-26O","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=8110"}],"version-history":[{"count":22,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8110\/revisions"}],"predecessor-version":[{"id":9456,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/8110\/revisions\/9456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/8127"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=8110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=8110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=8110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}