Merge Arrays JavaScript | Concat() Method

Merge Arrays JavaScript | Concat() Method

Javascript merge array of objects; In this tutorial, you will learn how to merge or combine two or more arrays in javascript with examples.

Merge Arrays JavaScript | Concat() Method

Array concat() method is an inbuilt javascript method, which is commonly used to combine or concatenate or merge two or more arrays in javaScript.

Note: This method merges or adds two or more arrays and returns a new single array.


The basic syntax of javascript concat() method is following:

array.concat(array_second, array_third, …, array_n);

Parameters of the concat() method

array_one, array_two,….. array_nThis is required. The arrays to be merged

Example first – Merge two arrays in javascript

Let’s take the first example, we have two array in javascript. We will merge those arrays using the concat() function of javascript. Let’s see the below:

      var array = ["php", "java"];
      var array2 = ["c", "c#", ".net"];
      var res = array.concat(array2);


The output of the above code is: (5) [“php”, “java”, “c”, “c#”, “.net”]

Example Second – Merge 3 arrays in javascript

We have 3 numeric array in javascript. In this example, we will merge or combine three javascript numeric arrays. Let’s see below:

      var array = [1,2,3];
      var array2 = [4,5,6];
      var array3 = [7,8,9,10];
      var res = array.concat(array2, array3);


The output of the above code is: (10) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


In this tutorial, you have learned how to merge two or more arrays together in javascript using the array concat() method of javascript.

Recommended JavaScript Tutorials

Recommended:-JavaScript Arrays


Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *