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

🌐
W3Schools
w3schools.com › jsref › jsref_push.asp
JavaScript Array push() Method
The push() method adds new items to the end of an array.
🌐
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.
🌐
W3Schools
w3schools.com › js › tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
W3Schools
w3schools.com › js › js_array_methods.asp
JavaScript Array Methods
The join() method also joins all array elements into a string. It behaves just like toString(), but in addition you can specify the separator: const fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo").innerHTML = fruits.join(" * "); Result: Banana * Orange * Apple * Mango Try it Yourself » · When you work with arrays, it is easy to remove elements and add new elements. This is what popping and pushing is: Popping items out of an array, or pushing items into an array.
🌐
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 - This article will show you how to insert an element into an array using JavaScript. In case you're in a hurry, here are the methods we'll be discussing in depth in this article: // Add to the start of an array Array.unshift(element); // Add to the end of an array Array.push(element); // Add to a specified location Array.splice(start_position, 0, new_element...); // Add with concat method without mutating original array let newArray = [].concat(Array, element);
🌐
DEV Community
dev.to › technoph1le › the-javascript-arraypush-method-explained-5d4m
The JavaScript `Array.push()` method explained - DEV Community
November 24, 2022 - The Array.push() method adds one or more elements to the end of an array and returns the new length... Tagged with webdev, beginners, javascript.
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.

🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › array.prototype.push()
JavaScript Array Push
November 6, 2024 - Summary: in this tutorial, you’ll learn how to use the JavaScript Array push() method to append one or more elements to an array.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-array-push-method
JavaScript Array push() Method - GeeksforGeeks
... function func() { // Original array let arr = [34, 234, 567, 4]; // Pushing the elements arr.push(23, 45, 56); console.log(arr); } func(); ... The `push()` method in JavaScript arrays is used to add one or more elements to the end of an array.
Published   April 15, 2025
🌐
W3Schools
w3schools.com › js › js_arrays.asp
JavaScript Arrays
The easiest way to add a new element to an array is using the push() method:
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Array › push
JavaScript Array push() - Add Elements to Array | Vultr Docs
September 27, 2024 - In this article, you will learn how to effectively utilize the push() method to add elements to an array. Explore practical examples that demonstrate how to add single and multiple items, understand how push() impacts the original array, and see how it interacts with other JavaScript functionalities.
🌐
Stack Abuse
stackabuse.com › bytes › push-an-object-to-an-array-in-javascript
Push an Object to an Array in JavaScript
July 23, 2022 - You can also achieve the same thing by passing the object directly to the push() method, without first assigning it to a variable. let array = []; array.push({ name: 'Billy', age: 30, role: 'admin' }); console.log(array); // [{name: 'Billy', age: 30, role: 'admin'}]
🌐
CodyHouse
codyhouse.co › blog › post › javascript-append-to-array
JavaScript quick tip - append to array with examples | CodyHouse
An overview of appending elements to an array in JavaScript. ... In this tutorial, we want to share some quick tips on appending elements to an array. The push method can be used to append an element at the end of an array.
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript array push method
Understanding JavaScript Array push Method
September 1, 2008 - Explore the JavaScript Array push method to efficiently add elements to your arrays. Step-by-step examples and detailed explanations.
🌐
Shiksha
shiksha.com › home › it & software › it & software articles › programming articles › javascript array push
JavaScript Array Push - Shiksha Online
December 18, 2023 - The JavaScript array.push() method adds one or more elements to the end of an array, directly modifying the original array.
🌐
Sololearn
sololearn.com › en › Discuss › 1699679 › how-to-push-and-array-into-another-array
How to push and array into another array | Sololearn: Learn to code for FREE!
Here you go: var array1 = [{name: "Whitney"}, {name: "Cher"}, {name: "Tina"},{name: "Celine"}, {name: "Madonna"}, {name: "Janet"}]; var array2 = [{name: "Tina"}, {name: "Madonna"}]; function createNewArray() { var arr = []; for (var i = 0; i < array1.length; i++) { var j; for (var j = 0; j < array2.length; j++) { if (array1[i].name === array2[j].name) break; } if(j===array2.length) arr.push(array1[i]); } return arr; } array3 = createNewArray(); console.log("array3 = " + JSON.stringify(array3)); https://code.sololearn.com/Wvrx32Ax0AkD/#js