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
🌐
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.
🌐
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
Discussions

How to extend an existing JavaScript array with another array, without creating a new array - Stack Overflow
Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal. ... Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... There doesn't seem to be a way to extend an existing JavaScript array ... More on stackoverflow.com
🌐 stackoverflow.com
Append an array to another array in JavaScript - Stack Overflow
Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal. ... Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Closed 13 years ago. This question is an exact duplicate of: How to append an array to an existing JavaScript ... More on stackoverflow.com
🌐 stackoverflow.com
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
How can I add an element to an array?
What is the method to append an object (like a string or a number) to an array in JavaScript? More on community.latenode.com
🌐 community.latenode.com
5
October 5, 2024
People also ask

What is the fastest way to add an element to the beginning of a JavaScript array?
For arrays with fewer than 10,000 elements, unshift() provides the fastest performance when mutation is acceptable. For immutable operations, the spread operator offers the best combination of performance and readability. For very large arrays (100,000+ elements), consider using concat() or building a new array with a loop.
🌐
sencha.com
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 ...
Does unshift() modify the original array?
Yes, unshift() modifies the original array in place. It adds elements to the beginning and shifts existing elements to higher indices. If you need to preserve the original array, use the spread operator or concat() to create a new array instead.
🌐
sencha.com
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 ...
What is the time complexity of unshift()?
unshift() has O(n) time complexity, where n is the number of elements in the array. This is because all existing elements must be shifted to make room for new elements at the beginning.
🌐
sencha.com
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 ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array
Array - JavaScript | MDN
5 days ago - Note: If you're not yet familiar with array basics, consider first reading JavaScript First Steps: Arrays, which explains what arrays are, and includes other examples of common array operations. This example shows three ways to create new array: first using array literal notation, then using the Array() constructor, and finally using String.prototype.split() to build the array from a string.
🌐
daily.dev
daily.dev › home › blog › get into tech › add to list javascript: array manipulation basics
Add to List JavaScript: Array Manipulation Basics
December 22, 2025 - When you want to add elements to an array in JavaScript, you can use push() or unshift().
🌐
HostingAdvice
hostingadvice.com › home › how-to
JavaScript "Add to Array" Functions (push vs unshift vs others)
March 25, 2023 - The concat() method returns a new combined array comprised of the array on which it is called, joined with the array (or arrays) from its argument. To add some elements to another array using concat() do the following:
Find elsewhere
🌐
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
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);

🌐
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!

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › push
Array.prototype.push() - JavaScript | MDN
Instead, we store the collection on the object itself and use call on Array.prototype.push to trick the method into thinking we are dealing with an array—and it just works, thanks to the way JavaScript allows us to establish the execution context in any way we want. ... const obj = { length: 0, addElem(elem) { // obj.length is automatically incremented // every time an element is added.
🌐
freeCodeCamp
freecodecamp.org › news › insert-into-javascript-array-at-specific-index
How to Insert into a JavaScript Array at a Specific Index – JS Push
November 7, 2024 - In this code, the splice() method is called on the numbers array, starting at index 2, with a deleteCount of 0. You then add the new element 3 to the array at the start index. The result is the modified array [1, 2, 3, 4, 5]. In this article, you have learned the two major techniques for inserting elements into a JavaScript array at a specific index.
🌐
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 reduce() to get elements from a2 into a copy of a1. JavaScript · let a1 = [1, 2, 3]; let a2 = [4, 5, 6]; let result = a2.reduce((acc, val) => { acc.push(val); return acc; }, [...a1]); console.log(result); Output · [ 1, 2, 3, 4, 5, 6 ] It appends elements by modifying the original array. The elements of a2 are added at the end of a1 using splice().
🌐
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 - There are multiple different ways to properly do a "deep clone" of an array, but I will leave that for you as homework. When you want to add an element to the end of your array, use push(). If you need to add an element to the beginning of your ...
🌐
Latenode
community.latenode.com › other questions › javascript
How can I add an element to an array? - JavaScript - Latenode Official Community
October 5, 2024 - What is the method to append an object (like a string or a number) to an array in JavaScript?
🌐
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.
🌐
CodyHouse
codyhouse.co › blog › post › javascript-append-to-array
JavaScript quick tip - append to array with examples | CodyHouse
The unshift method, like the push method, can be used to combine arrays. The difference is that the unshift method adds at the beginning of the array, rather than the end.
🌐
JanBask Training
janbasktraining.com › community › java › how-to-extend-an-existing-javascript-array-with-another-array-without-creating-a-new-array
How to extend an existing JavaScript array with another array, without creating a new array | JanBask Training Community
September 11, 2025 - How can you extend an existing JavaScript array with another array without creating a new one, and what methods make this possible? Learn practical ways using push.apply() or the spread operator to merge arrays efficiently.
🌐
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. JavaScript ·
🌐
GitHub
gist.github.com › bcls › d9c7bb80818f47b06d800fda8823016a
Append array to another array #javascript · GitHub
Append array to another array #javascript · Raw · combineArrays.js · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
W3Schools
w3schools.com › js › js_array_methods.asp
JavaScript Array Methods
ES2019 added the Array flatMap() method to JavaScript.