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

Copy// 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:

Copy// 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):

Copyvar 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.

Copyvar 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.

Copyconst 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

🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-append-element-in-js-array
JavaScript- Append in Array - GeeksforGeeks
July 11, 2025 - ... We can also append arrays in the existing array by combining them together. JavaScript 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.
🌐
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:
Discussions

javascript - How to append something to an array? - Stack Overflow
If arr is an array, and val is the value you wish to add use: ... Save this answer. Show activity on this post. ... Save this answer. Show activity on this post. JavaScript with the ECMAScript 5 (ES5) standard which is supported by most browsers now, you can use apply() to append array1 to array2. 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
Add Items to an Array with push() and unshift()
Tell us what’s happening: what did I missing? Your code so far function mixedNumbers(arr) { // change code below this line arr.push("I", 2, "three"); arr.unshift(7, "VIII", 9); // change code above this line return arr; } // do not change code below this line console.log(mixedNumbers(['IV', ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
1
June 1, 2018
How can I add new array elements at the beginning of an array in JavaScript? - Stack Overflow
Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... New site design and philosophy for Stack Overflow: Starting February 24, 2026... I’m Jody, the Chief Product and Technology Officer at Stack Overflow, let’s... 735 javascript pushing element at the beginning of an array... More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › jsref › jsref_push.asp
JavaScript Array push() Method
The push() method adds new items to the end of an array.
Top answer
1 of 16
5428

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

Copy// 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:

Copy// 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):

Copyvar 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.

Copyvar 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.

Copyconst 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
1122

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

Copyvar 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:

Copyvar 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.

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › push
Array.prototype.push() - JavaScript | MDN
The push() method of Array instances adds the specified elements to the end of an array and returns the new length of the array.
🌐
W3Schools
w3schools.com › js › js_arrays.asp
JavaScript Arrays
JavaScript does not support associative arrays. You should use objects when you want the element names to be strings (text).
🌐
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 ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › add-new-elements-at-the-beginning-of-an-array-using-javascript
Insert at the Beginning of an Array in JavaScript - GeeksforGeeks
July 11, 2025 - Adding new elements at the beginning of the existing array can be done by using the Array unshift() method. This method is similar to the push() method but it adds an element at the beginning of the array.
🌐
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().
🌐
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 › 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.
🌐
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!

🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Add Items to an Array with push() and unshift() - JavaScript
June 1, 2018 - Tell us what’s happening: what did I missing? Your code so far function mixedNumbers(arr) { // change code below this line arr.push("I", 2, "three"); arr.unshift(7, "VIII", 9); // change code above this line return arr; } // do not change code below this line console.log(mixedNumbers(['IV', ...
🌐
freeCodeCamp
freecodecamp.org › news › how-to-add-and-remove-js-array-elements
How to Add and Remove Elements from Arrays in JavaScript
March 13, 2024 - If you need to add an element to the end of an array, you can use the push method. The push method adds one or more elements to the end of an array and returns the new length of the array.
Top answer
1 of 12
4058

Use unshift. It's like push, except it adds elements to the beginning of the array instead of the end.

  • unshift/push - add an element to the beginning/end of an array
  • shift/pop - remove and return the first/last element of an array

A simple diagram...

unshift -> [array] <- push
shift   <- [array] -> pop

and chart:

  add remove start end
push X X
pop X X
unshift X X
shift X X

Check out the MDN Array documentation. Virtually every language that has the ability to push/pop elements from an array will also have the ability to unshift/shift (sometimes called push_front/pop_front) elements, you should never have to implement these yourself.


As pointed out in the comments, if you want to avoid mutating your original array, you can use concat, which concatenates two or more arrays together. You can use this to functionally push a single element onto the front or back of an existing array; to do so, you need to turn the new element into a single element array:

const array = [3, 2, 1]

const newFirstElement = 4

const newArray = [newFirstElement].concat(array) // [ 4, 3, 2, 1 ]

console.log(newArray);

concat can also append items. The arguments to concat can be of any type; they are implicitly wrapped in a single-element array, if they are not already an array:

const array = [3, 2, 1]

const newLastElement = 0

// Both of these lines are equivalent:
const newArray1 = array.concat(newLastElement) // [ 3, 2, 1, 0 ]
const newArray2 = array.concat([newLastElement]) // [ 3, 2, 1, 0 ]

console.log(newArray1);
console.log(newArray2);

2 of 12
1761

var a = [23, 45, 12, 67];
a.unshift(34);
console.log(a); // [34, 23, 45, 12, 67]

🌐
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript array push
JavaScript Array Push | Adding Elements in Array with Different Examples
June 9, 2023 - We can add single or multiple items at the beginning using unshift() method, and similar to the push() method, this also returns us the new length of the array. ... Note that the push() method and all the above methods work only on ECMAScript 1 version of javascript and supported browsers, and their minimum versions that support these methods are as follows.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
CoreUI
coreui.io › answers › how-to-add-an-item-to-an-array-in-javascript
How to add an item to an array in JavaScript · CoreUI
September 18, 2025 - From my expertise, the most efficient and widely supported method is using the push() method to add items to the end of an array. This approach is performant, intuitive, and works consistently across all JavaScript environments.
🌐
egghead.io
egghead.io › lessons › javascript-add-elements-onto-an-array-with-push
Add Elements onto an Array with Push | egghead.io
To show array push in use we'll use an array to represent the list items. When we type into this input box and click add, we'll push the value onto the array and then display them in the list. [02:17] Then in the JavaScript we first get a reference to each DOM element that we need, then we initialize the pets array, we add an event listener to the button so that we can respond to clicks, and then we have a render function that takes the pets array, generates a list item for each element in it, joins them together, and then sets that is the innerHTML on that list.
Published   April 9, 2016
🌐
W3Schools
w3schools.com › js › js_array_methods.asp
JavaScript Array Methods
When you work with arrays, it is easy to remove elements and add new elements.