---
title: "JavaScript Combine Two Arrays"
date: 2021-11-07T23:07:41.000Z
author: Z.SHINCHVEN
tags: [JavaScript, Array]
canonical: https://atlassc.net/2021/11/08/javascript-combine-two-arrays
---
## Array.prototype.push()

The [push()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) method adds one `or more elements` to the end of an array and returns the new length of the array.

### Syntax

```JavaScript
push(element0)
push(element0, element1)
push(element0, element1, ... , elementN)
```
### Example

```JavaScript
const array1 = [1, 2, 3, 4];
const array2 = [5, 6, 7, 8];
array1.push(...array2);
// expected output: Array [1, 2, 3, 4, 6, 7, 8]
```

## Array.prototype.concat()

The [concat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) method is used to merge two or more arrays. This method does not change the existing arrays, but instead `returns a new array`.


### Syntax

```JavaScript
concat()
concat(value0)
concat(value0, value1)
concat(value0, value1, ... , valueN)
```

### Example

```JavaScript
const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);

console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
```
