If you want to modify the original array instead of returning a new array, use .push()...

array1.push.apply(array1, array2);
array1.push.apply(array1, array3);

I used .apply to push the individual members of arrays 2 and 3 at once.

or...

array1.push.apply(array1, array2.concat(array3));

To deal with large arrays, you can do this in batches.

for (var n = 0, to_add = array2.concat(array3); n < to_add.length; n+=300) {
    array1.push.apply(array1, to_add.slice(n, n+300));
}

If you do this a lot, create a method or function to handle it.

var push_apply = Function.apply.bind([].push);
var slice_call = Function.call.bind([].slice);

Object.defineProperty(Array.prototype, "pushArrayMembers", {
    value: function() {
        for (var i = 0; i < arguments.length; i++) {
            var to_add = arguments[i];
            for (var n = 0; n < to_add.length; n+=300) {
                push_apply(this, slice_call(to_add, n, n+300));
            }
        }
    }
});

and use it like this:

array1.pushArrayMembers(array2, array3);

Show code snippet

var push_apply = Function.apply.bind([].push);
var slice_call = Function.call.bind([].slice);

Object.defineProperty(Array.prototype, "pushArrayMembers", {
    value: function() {
        for (var i = 0; i < arguments.length; i++) {
            var to_add = arguments[i];
            for (var n = 0; n < to_add.length; n+=300) {
                push_apply(this, slice_call(to_add, n, n+300));
            }
        }
    }
});

var array1 = ['a','b','c'];
var array2 = ['d','e','f'];
var array3 = ['g','h','i'];

array1.pushArrayMembers(array2, array3);

document.body.textContent = JSON.stringify(array1, null, 4);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Top answer
1 of 1
186

If you want to modify the original array instead of returning a new array, use .push()...

array1.push.apply(array1, array2);
array1.push.apply(array1, array3);

I used .apply to push the individual members of arrays 2 and 3 at once.

or...

array1.push.apply(array1, array2.concat(array3));

To deal with large arrays, you can do this in batches.

for (var n = 0, to_add = array2.concat(array3); n < to_add.length; n+=300) {
    array1.push.apply(array1, to_add.slice(n, n+300));
}

If you do this a lot, create a method or function to handle it.

var push_apply = Function.apply.bind([].push);
var slice_call = Function.call.bind([].slice);

Object.defineProperty(Array.prototype, "pushArrayMembers", {
    value: function() {
        for (var i = 0; i < arguments.length; i++) {
            var to_add = arguments[i];
            for (var n = 0; n < to_add.length; n+=300) {
                push_apply(this, slice_call(to_add, n, n+300));
            }
        }
    }
});

and use it like this:

array1.pushArrayMembers(array2, array3);

Show code snippet

var push_apply = Function.apply.bind([].push);
var slice_call = Function.call.bind([].slice);

Object.defineProperty(Array.prototype, "pushArrayMembers", {
    value: function() {
        for (var i = 0; i < arguments.length; i++) {
            var to_add = arguments[i];
            for (var n = 0; n < to_add.length; n+=300) {
                push_apply(this, slice_call(to_add, n, n+300));
            }
        }
    }
});

var array1 = ['a','b','c'];
var array2 = ['d','e','f'];
var array3 = ['g','h','i'];

array1.pushArrayMembers(array2, array3);

document.body.textContent = JSON.stringify(array1, null, 4);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › concat
Array.prototype.concat() - JavaScript | MDN
The concat() method of Array instances is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.
Discussions

Append array to array - The freeCodeCamp Forum
Can’t seem to find the answer to this, but I’m trying to use push to add an array on the end of another, not insert it. So myArray.push(otherArray); gives me something like [“a”,“b”,[“c”,“d”]] but what I’m trying to get is [“a”,“b”][“c”,“d”] Help is greatly ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
October 15, 2016
Can you only add an array to another array?
Push: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push const numbers = [1, 2, 3]; numbers.push(4); console.log(numbers); // [1, 2, 3, 4] const arrays = [[1, 2], [3, 4]]; arrays.push([5, 6]); console.log(arrays); // [[1, 2], [3, 4], [5, 6]] const whatever = [{ name: 'Sue' }, false, null]; whatever.push('eleventy'); console.log(whatever); // [{ name: 'Sue' }, false, null, 'eleventy'] Concat: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat const odds = [1, 3]; const evens = [2, 4]; const all = odds.concat(evens); console.log(odds); // [1, 3] console.log(evens); // [2, 4] console.log(all); // [1, 3, 2, 4] Spread operator: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax const odds = [1, 3]; const evens = [2, 4]; const all = [...odds, ...evens]; console.log(odds); // [1, 3] console.log(evens); // [2, 4] console.log(all); // [1, 3, 2, 4] More on reddit.com
🌐 r/learnjavascript
9
6
October 4, 2022
Append an Array to an Array of Arrays in JavaScript - Stack Overflow
I started working with JavaScript last week in order to create some D3 visualizations, and have become rather stuck on what can only be a very simple task. I have various data series for different More on stackoverflow.com
🌐 stackoverflow.com
javascript - How to append something to an array? - Stack Overflow
How do I append an object (such as a string or number) to an array in JavaScript? More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-append-array-at-the-end-of-another-array
JavaScript - Append Array At The End Of Another Array - GeeksforGeeks
July 23, 2025 - It uses push() combined with the spread operator to append elements of a2 to a1. ... It concatenates a1 and a2 into a new array, preserving the original arrays.
🌐
CodyHouse
codyhouse.co › blog › post › javascript-append-to-array
JavaScript quick tip - append to array with examples | CodyHouse
In the example above, we use the handleEvent function to handle multiple dragging events. If you are unfamiliar with this technique, take a look at this article on handling events in JavaScript and keeping them organized. In the storeDroppedFiles function, we update the dropped_files array: function storeDroppedFiles(new_files) { dropped_files.push(...new_files); } Each time the user drops new files, they will be appended to the dropped_files array.
🌐
freeCodeCamp
forum.freecodecamp.org › t › append-array-to-array › 45740
Append array to array - The freeCodeCamp Forum
October 15, 2016 - Can't seem to find the answer to this, but I'm trying to use push to add an array on the end of another, not insert it. So myArray.push(otherArray); gives me something like ["a","b",["c","d"]] but what I'm tryin…
Find elsewhere
🌐
Reddit
reddit.com › r/learnjavascript › can you only add an array to another array?
r/learnjavascript on Reddit: Can you only add an array to another array?
October 4, 2022 -

Hi there!

I'm new to JavaScript and was learning about arrays today and saw that the instructor only added an array to another array. Is it possible to add something that is not an array into an array? Iyes, how can I do that?

Thanks in advance!

🌐
Sentry
sentry.io › sentry answers › javascript › how do you append something to an array using javascript?
JavaScript Append to an Array | Sentry
3 weeks ago - Use push(), spread syntax, concat(), or the length property to add one or more items to a JavaScript array
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › push
Array.prototype.push() - JavaScript | MDN
July 12, 2026 - The element(s) to add to the end of the array. The new length property of the object upon which the method was called. The push() method appends values to an array.
🌐
Renovate Docs
docs.renovatebot.com › configuration-options
Configuration Options - Renovate Docs
If a config option has a parent defined, it means it's only allowed to configure it within an object with the parent name, such as packageRules or hostRules. When an array or object configuration option is mergeable, it means that values inside it will be added to any existing object or array that existed with the same name.
🌐
Codegive
codegive.com › blog › js_append_in_array.php
js append in array: Master JavaScript Array Manipulation (2024) & Unlock Advanced Techniques!
Merging one array into another (effectively appending all elements of the second array to the first). Creating a new array that includes all elements from an original array plus the newly appended elements, leaving the original array untouched (immutable approach). Understanding these different interpretations is key, as JavaScript offers several methods, each with its own behavior regarding mutability (whether the original array is changed) and performance characteristics.
🌐
Three.js
threejs.org › docs
three.js docs
ArrayElementNode · ArrayNode · AssignNode · AtomicFunctionNode · AttributeNode · BarrierNode · BasicEnvironmentNode · BasicLightMapNode · BasicLightingModel · BitcastNode · BitcountNode · BufferAttributeNode · BufferNode · BuiltinNode · BumpMapNode ·
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-append-array-at-specific-position-of-another-array
JavaScript - Append Array at Specific Position of Another Array - GeeksforGeeks
July 23, 2025 - Here are the different approaches to appending an array at a specific position within another array in JavaScript.
🌐
D3
d3js.org › getting-started
Getting started | D3 by Observable
D3 works in any JavaScript environment. The fastest way to get started (and get help) with D3 is on Observable! D3 is available by default in notebooks as part of Observable’s standard library. To create something with D3, return the generated DOM element from a cell.
🌐
Appsmith
community.appsmith.com › content › blog › joining-arrays-javascript
Joining Arrays in Javascript | Appsmith Community Portal
December 3, 2024 - Mutates Original Arrays? Yes. Notes: This works just like push() but adds the elements to the start of the array.
🌐
Altcademy
altcademy.com › blog › how-to-add-to-an-array-in-javascript
How to add to an array in JavaScript
August 28, 2023 - You can keep adding items (elements) to your list (array) as needed, either at the end, the beginning, or even in the middle of your list. The methods push(), unshift(), and splice() are your tools to do just that in JavaScript.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-extend-an-existing-array-with-another-array-without-creating-a-new-array-in-javascript
Extend existing JS array with Another Array - GeeksforGeeks
July 23, 2025 - To extend an array with another without creating a new array we can use the JavaScript array.push() method. This method extend the array by adding the elements at the end.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-add-two-arrays-into-a-new-array-in-javascript
How to add two arrays into a new array in JavaScript?
January 18, 2023 - Additionally, each of these methods ... work and know when it is best to use them. The concat() method connects two or more arrays and returns a new array comprising the combined arrays....
Top answer
1 of 16
5430

Use the Array.prototype.push method to append values to the end of an array:

// initialize array
var arr = [
  "Hi",
  "Hello",
  "Bonjour"
];

// append new value to the array
arr.push("Hola");

console.log(arr);
Run code snippetEdit code snippet Hide Results Copy to answer Expand


You can use the push() function to append more than one value to an array in a single call:

// initialize array
var arr = ["Hi", "Hello", "Bonjour", "Hola"];

// append multiple values to the array
arr.push("Salut", "Hey");

// display all values
for (var i = 0; i < arr.length; i++) {
  console.log(arr[i]);
}
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Note that the push() method returns the updated length of the array.


Update

If you want to add the items of one array to another array, you can use firstArray.concat(secondArray):

var arr = [
  "apple",
  "banana",
  "cherry"
];

// Do not forget to assign the result as, unlike push, concat does not change the existing array
arr = arr.concat([
  "dragonfruit",
  "elderberry",
  "fig"
]);

console.log(arr);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Update

Just an addition to this answer if you want to prepend any value to the start of an array (i.e. first index) then you can use Array.prototype.unshift for this purpose.

var arr = [1, 2, 3];
arr.unshift(0);
console.log(arr);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

It also supports appending multiple values at once just like push.


Update

Another way with ES6 syntax is to return a new array with the spread syntax. This leaves the original array unchanged, but returns a new array with new items appended or prepended, compliant with the spirit of functional programming.

const arr1 = [
  "Hi",
  "Hello",
  "Bonjour",
];
const arr2 = [
  "Ciao",
  "Hej",
  "Merhaba",
];

const newArr1 = [
  ...arr1,
  "Salut",
];
const newArr2 = [
  "Salut",
  ...arr2,
];
const newArr3 = [
  ...arr1,
  ...arr2,
];

console.log(newArr1, newArr2, newArr3);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

2 of 16
1123

If you're only appending a single variable, then push() works just fine. If you need to append another array, use concat():

var ar1 = [1, 2, 3];
var ar2 = [4, 5, 6];

var ar3 = ar1.concat(ar2);

alert(ar1);
alert(ar2);
alert(ar3);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

The concat does not affect ar1 and ar2 unless reassigned, for example:

var ar1 = [1, 2, 3];
var ar2 = [4, 5, 6];

ar1 = ar1.concat(ar2);
alert(ar1);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

There is a lot of great information on JavaScript Reference.