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

🌐
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…
🌐
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];
Discussions

javascript - How to append something to an array? - Stack Overflow
How do I append an object (such as a string or number) to an array in JavaScript? More on stackoverflow.com
🌐 stackoverflow.com
Three ways to append an item to an array (Mutative)
myArray = [...myArray, 'Pig'] :) More on reddit.com
🌐 r/learnjavascript
33
131
September 1, 2022
How do I append to an array inside a json file in node?
If it's stored as JSON, you'd read the JSON in, parse it to JavaScript structures using JSON.parse, push the new messages to the JSON, reserialize it back to JSON, then re-write to to disk. This is quite inefficient though. It would be better to use a database. More on reddit.com
🌐 r/learnjavascript
14
4
December 26, 2022
Check checkbox check state and append to array
Since you are using jQuery, it would be easiest to leverage its :checked selector , e.g.: $(".form-check input[type=checkbox]:checked") would return a jQuery collection containing all checked checkboxes inside .form-check element(s). Once you have that collection, you can use rest of jQuery methods, or convert it to Array and use plain JS or other library's methods, something like this example (note that you can inline getChecked function right into .click(), but I thought it was worth extracting it). More on reddit.com
🌐 r/learnjavascript
6
3
January 23, 2018
🌐
Python
docs.python.org › 3 › library › pickle.html
pickle — Python object serialization
1 week ago - If the object has no such method then, the value must be a dictionary and it will be added to the object’s __dict__ attribute. Optionally, an iterator (and not a sequence) yielding successive items. These items will be appended to the object either using obj.append(item) or, in batch, using obj.extend(list_of_items).
🌐
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.
🌐
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
🌐
Java67
java67.com › 2021 › 12 › how-to-append-element-to-array-in.html
How to append an element to an array in JavaScript? Example Tutorial | Java67
That's all about how to append to an array in JavaScript. You have learned 5 ways to achieve this common task, 3 of them are mutative which means they will change the original array, and two of them will return a new array. If you remember, push, splice, and length will mutate the original 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.

Find elsewhere
🌐
npm
npmjs.com › package › multer
multer - npm
2 days ago - Then in your javascript file you would add these lines to access both the file and the body. It is important that you use the name field value from the form in your upload function. This tells multer which field on the request it should look for the files in.
      » npm install multer
    
Published   Feb 27, 2026
Version   2.1.0
🌐
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...
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-append-element-in-js-array
JavaScript- Append in Array - GeeksforGeeks
July 11, 2025 - JavaScript array.push() Method is used to add one or more elements to the end of the array.
🌐
Reddit
reddit.com › r/learnjavascript › three ways to append an item to an array (mutative)
r/learnjavascript on Reddit: Three ways to append an item to an array (Mutative)
September 1, 2022 - Also, JavaScript arrays are dynamic, so pushing into the array has an amortized time complexity of O(1), aka as cheap as it can realistically be. ... The last is a bad practice, because of reasons. (async, e.g.) The middle one is more for splicing multiple arrays together.
🌐
CapsCode
capscode.in › blog › different-ways-to-insert-element-in-array-in-javascript
6 Ways To Insert Element In Array
November 6, 2021 - ... let array = ["1", "2", "3"]; array.push("4", "5", "6"); console.log(array); // returns ['1', '2', '3', '4', '5', '6'] You can append an array to an existing array by using push.apply()
🌐
Altcademy
altcademy.com › blog › how-to-add-elements-to-an-array-in-javascript
How to add elements to an array in JavaScript
August 25, 2023 - Similarly, you can use unshift() and splice() to add multiple elements. In JavaScript, an array can hold any type of values including objects.
🌐
Select2
select2.org › getting-started › basic-usage
Basic usage | Select2 - The jQuery replacement for select boxes
Select2 will register itself as a jQuery function if you use any of the distribution builds, so you can call .select2() on any jQuery selector where you would like to initialize Select2. // In your Javascript (external .js resource or <script> tag) $(document).ready(function() { $('.js-example-basic-single').select2(); });
🌐
TecAdmin
tecadmin.net › append-item-to-array-in-javascript
How to Append an Item to Array in JavaScript – TecAdmin
April 26, 2025 - The following example creates an initial array with two elements (as “black”,”blue”). After that use javascript push() function to append new element (“white”) to the array.
🌐
React
react.dev › learn › rendering-lists
Rendering Lists – React
You will often want to display multiple similar components from a collection of data. You can use the JavaScript array methods to manipulate an array of data.
🌐
React
legacy.reactjs.org › docs › optimizing-performance.html
Optimizing Performance – React
ES6 supports a spread syntax for arrays which can make this easier. If you’re using Create React App, this syntax is available by default. handleClick() { this.setState(state => ({ words: [...state.words, 'marklar'], })); }; You can also rewrite code that mutates objects to avoid mutation, in a similar way.
🌐
Zod
zod.dev › api
Defining schemas | Zod
To define a self-referential type, use a getter on the key. This lets JavaScript resolve the cyclical schema at runtime. const Category = z.object({ name: z.string(), get subcategories(){ return z.array(Category) } }); type Category = z.infer<typeof Category>; // { name: string; subcategories: Category[] }
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-add-an-object-to-an-array-in-javascript
JavaScript- Add an Object to JS Array - GeeksforGeeks
arr = [...arr, obj]; – The spread operator (...) creates a new array by copying all elements of arr and appending the object obj at the end. console.log(arr); – Logs the updated array. The splice() method is more flexible and allows you to add an object to an array at a specific index. It can be used to add, remove, or replace elements in an array. JavaScript ·
Published   July 12, 2025