The .push method can take multiple arguments. You can use the spread operator to pass all the elements of the second array as arguments to .push:

>>> a.push(...b)

If your browser does not support ECMAScript 6, you can use .apply instead:

>>> a.push.apply(a, b)

Or perhaps, if you think it's clearer:

>>> Array.prototype.push.apply(a,b)

Please note that all these solutions will fail with a stack overflow error if array b is too long (trouble starts at about 100,000 elements, depending on the browser).
If you cannot guarantee that b is short enough, you should use a standard loop-based technique described in the other answer.

Answer from Dzinx on Stack Overflow
๐ŸŒ
Xojo Programming Forum
forum.xojo.com โ€บ general
Append an array to an array? - General - Xojo Programming Forum
February 11, 2014 - I have three string arrays dim one(-1), two(-1), three(-1) as string dim all(-1) as string .... all.append(one) all.append(two) all.append(three) Whatโ€™s the best way to concatenate these three arrays into one array?
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array โ€บ concat
Array.prototype.concat() - JavaScript | MDN
Then, for each argument, its value will be concatenated into the array โ€” for normal objects or primitives, the argument itself will become an element of the final array; for arrays or array-like objects with the property Symbol.isConcatSpreadable set to a truthy value, each element of the argument will be independently added to the final array.
Discussions

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 array to array
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
How can I add the elements of one JavaScript array to another without creating a new array?
It seems challenging to merge the elements of one existing JavaScript array into another, similar to Pythonโ€™s extend method. I am looking for a solution to perform the following operation: let x = [1, 2]; let y = [3, 4,โ€ฆ More on community.latenode.com
๐ŸŒ community.latenode.com
0
December 5, 2024
Append an array to another array in JavaScript - Stack Overflow
This question is an exact duplicate of: How to append an array to an existing JavaScript Array? How do you append an array to another array in JavaScript? Other ways that a person might word this More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ javascript โ€บ array-concatenation
JavaScript Array Concatenate: Syntax, Usage, and Examples
Merge arrays in JavaScript using concat(), the spread operator (...), or push(). Quickly combine lists, results, or values without loops.
๐ŸŒ
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.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ javascript-add-array-to-array-of-array
JavaScript - Add Array to Array of Array - GeeksforGeeks
July 23, 2025 - It can be used to add an array to an array of arrays by expanding both arrays into a new array. ... [...arrOfArr, newArr] creates a new array by spreading the elements of arrOfArr and then appending the newArr at the end.
๐ŸŒ
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!

Find elsewhere
๐ŸŒ
SamanthaMing
samanthaming.com โ€บ tidbits โ€บ 87-5-ways-to-append-item-to-array
5 Way to Append Item to Array in JavaScript | SamanthaMing.com
5 ways to add an item to the end of an array. Push, Splice, and Length will mutate the original array. Concat and Spread won't and will return a new array...
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_push.asp
JavaScript Array push() Method
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST ... Array[ ] Array( ) at() concat() constructor copyWithin() entries() every() fill() filter() find() findIndex() findLast() findLastIndex() flat() flatMap() forEach() from() includes() indexOf() isArray() join() keys() lastIndexOf() length map() of() pop() prototype push() reduce() reduceRight() rest (...) reverse() shift() slice() some() sort() splice() spread (...) toReversed() toSorted() toSpliced() toString() unshift() values() valueOf() with() JS Boolean
๐ŸŒ
Medium
habtesoft.medium.com โ€บ add-elements-to-an-array-in-javascript-a9cc6cd9469f
Add elements to an array in JavaScript | by habtesoft | Medium
October 18, 2024 - One of the simplest ways to add an element to an array in JavaScript is to use the push() method.
๐ŸŒ
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.
๐ŸŒ
Futurestud.io
futurestud.io โ€บ tutorials โ€บ append-an-item-at-the-end-of-an-array-in-javascript-or-node-js
Append an Item at the End of an Array in JavaScript or Node.js
February 11, 2021 - Arrays are a commonly used data structure in JavaScript applications. Arrays represent a list of items that you can manipulate to your own needs. You can add new items to an existing array with ease. This tutorial shows you three ways of appending new items to the end of an existing array.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ javascript-array-insert-how-to-add-to-an-array-with-the-push-unshift-and-concat-functions
JavaScript Array Insert - How to Add to an Array with the Push, Unshift, and Concat Functions
August 25, 2020 - The first and probably the most common JavaScript array method you will encounter is push(). The push() method is used for adding an element to the end of an 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โ€ฆ
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ javascript โ€บ how do you append something to an array using javascript?
How do you append something to an array using JavaScript? | Sentry
January 30, 2023 - This method takes in elements to add to the array as arguments, changes the original array, and returns the new length of the array. You can append one or more items to an array using spread syntax:
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ jsref_concat_array.asp
JavaScript Array concat() Method
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST ... Array[ ] Array( ) at() concat() constructor copyWithin() entries() every() fill() filter() find() findIndex() findLast() findLastIndex() flat() flatMap() forEach() from() includes() indexOf() isArray() join() keys() lastIndexOf() length map() of() pop() prototype push() reduce() reduceRight() rest (...) reverse() shift() slice() some() sort() splice() spread (...) toReversed() toSorted() toSpliced() toString() unshift() values() valueOf() with() JS Boolean
๐ŸŒ
Latenode
community.latenode.com โ€บ other questions โ€บ javascript
How can I add the elements of one JavaScript array to another without creating a new array? - JavaScript - Latenode Official Community
December 5, 2024 - I am looking for a solution to perform the following operation: let x = [1, 2]; let y = [3, 4, 5]; // What should I do here? console.log(x); // This should output: [1, 2, 3, 4, 5] While I am aware of the x.concat(y) method, this approach generates ...
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array โ€บ push
Array.prototype.push() - JavaScript | MDN
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.
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);

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);

๐ŸŒ
Sencha
sencha.com โ€บ home โ€บ blog โ€บ how to add elements to the beginning of an array in javascript (2026 guide)
How to Add Elements to the Beginning of an Array in JavaScript (2026 Guide)
March 14, 2024 - Understanding the internal mechanics helps explain why unshift() has O(n) time complexity. When you call unshift(), the JavaScript engine executes these steps: Calculate new length: Determine how many elements to add and compute the resulting array size