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

๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ Array โ€บ push
Array.prototype.push() - JavaScript | MDN
July 12, 2026 - 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. js ยท const obj = { length: 0, addElem(elem) { // obj.length is automatically incremented // every time an element is added.
๐ŸŒ
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
Array - JavaScript | MDN
July 28, 2026 - Adds one or more elements to the front of an array, and returns the new length of the array. ... Returns a new array iterator object that contains the values for each index in the array. ... Returns a new array with the element at the given index replaced with the given value, without modifying ...
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.

Top answer
1 of 12
4070

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);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

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);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

2 of 12
1760

var a = [23, 45, 12, 67];
a.unshift(34);
console.log(a); // [34, 23, 45, 12, 67]
Run code snippetEdit code snippet Hide Results Copy to answer Expand

๐ŸŒ
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.
Find elsewhere
๐ŸŒ
daily.dev
daily.dev โ€บ home โ€บ blog โ€บ webdev โ€บ add to list javascript: array manipulation basics
Add to List JavaScript: Array Manipulation Basics | daily.dev
May 25, 2026 - Learn how to manipulate arrays in JavaScript by adding, combining, and inserting elements at specific positions. Master core methods like push(), unshift(), splice(), and concat().
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-insert-an-element-into-an-array-in-javascript
Push into an Array in JavaScript โ€“ How to Insert an Element into an Array in JS
November 7, 2024 - If you want to add an element to a particular location of your array, use splice(). And finally, when you want to maintain your original array, you can use the concat() method. In JavaScript, you use the unshift() method to add one or more elements to the beginning of an array and it returns the array's length after the new elements have been added.
๐ŸŒ
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
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ javascript-append-to-array-a-js-guide-to-the-push-method-2
JavaScript Append to Array: a JS Guide to the Push Method
April 19, 2021 - Sometimes you need to append one or more new values at the end of an array. In this situation the push() method is what you need. The push() method will add one or more arguments at the end of an array in JavaScript: let arr = [0, 1, 2, 3];
๐ŸŒ
Roblox Developer Forum
devforum.roblox.com โ€บ feature requests โ€บ engine features
CSG Instance that allows for easily modifying specific parts that make up the CSG object without regenrating the entire CSG object - Engine Features - Developer Forum | Roblox
April 6, 2026 - Currently Iโ€™m working on roof generation for my game which uses an old roblox artstyle, so my roof generation code canโ€™t just use wedges like Welcome To Bloxburg, and instead has to use blocks which greatly increases the part count of my roofs. Especially when my roofs have to be perfectly ...
๐ŸŒ
Quora
quora.com โ€บ What-method-can-you-use-to-add-an-element-to-an-array-in-JavaScript
What method can you use to add an element to an array in JavaScript? - Quora
Answer (1 of 2): To add elements to an array there are three methods that are available. 1. Push 2. unshift 3. splice The push method is used to add elements at the end of the array. The push method returns the new length of the array after inserting the element. [code]var arr=[1]; arr.push(2);...
๐ŸŒ
JavaScript in Plain English
javascript.plainenglish.io โ€บ javascript-tip-conditionally-add-an-item-to-an-array-5877a9d7c88b
JavaScript Tip: Conditionally Add an Item to an Array | by Chad Murobayashi | JavaScript in Plain English
July 30, 2021 - JavaScript Tip: Conditionally Add an Item to an Array Using the spread syntax and conditional ternary operator One thing I have learned throughout my time programming is that there is a solution to โ€ฆ
๐ŸŒ
Attacomsian
attacomsian.com โ€บ blog โ€บ javascript-array-add-items
How to add items to an array in JavaScript
May 20, 2020 - In vanilla JavaScript, you can use the Array.push() method to add new items to an array.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ javascript โ€บ examples โ€บ append-an-object-to-an-array
JavaScript Program to Append an Object to An Array | Vultr Docs
November 8, 2024 - Initialize an array of objects. Create the object you want to append. Use push() to add the object to the array.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ add-elements-to-a-javascript-array
How to Add Elements to a JavaScript Array? - GeeksforGeeks
July 23, 2025 - The push() method adds one or more elements to the end of an array and returns the new length of the array.
๐ŸŒ
DEV Community
dev.to โ€บ d8578raj โ€บ add-elements-to-javascript-array-31jn
Add Elements to JavaScript Array - DEV Community
June 29, 2024 - JavaScript provides multiple methods to accomplish this task, each suitable for different scenarios. The push() method adds one or more elements to the end of an array and returns the new length of the array.