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);


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]);
}

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);

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);

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);

🌐
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. ... const obj = { length: 0, addElem(elem) { // obj.length is automatically incremented // every time an element is added.
Discussions

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
In ES5 Javascript, how do I add an item to an array and return the new array immediately, without using concat? - Stack Overflow
I often find myself in the situation where I want to, in a single (atomic) operation, add an item to an array and return that new array. ['a', 'b'].push('c'); won't work as it returns the new leng... More on stackoverflow.com
🌐 stackoverflow.com
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
0
5
October 5, 2024
Three ways to append an item to an array (Mutative)
myArray = [...myArray, 'Pig'] :) More on reddit.com
🌐 r/learnjavascript
33
131
September 1, 2022
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);


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]);
}

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);

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);

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);

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);

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);

There is a lot of great information on JavaScript Reference.

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

🌐
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.
Find elsewhere
🌐
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.
🌐
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];
🌐
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().
🌐
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 the original array. ... An alias for the values() method by default. This section provides some examples of common array operations in JavaScript...
🌐
Sencha
sencha.com › home › blog › how to add elements to the beginning of a javascript array: complete guide (2026)
Add Elements to Array Start in JavaScript - 2026 Guide
May 11, 2026 - Best for JavaScript developers who need to understand the performance implications of array prepending in production applications. ... unshift() is the simplest method for adding elements to the start of an array, but it mutates the original array and has O(n) time complexity
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-add-an-object-to-an-array-in-javascript
JavaScript- Add an Object to JS Array - GeeksforGeeks
The push() method is used to add one or multiple elements to the end of an array. It returns the new length of the array formed.
Published: July 12, 2025
Top answer
1 of 2
9

I know the following code works ['a', 'b'].concat(['c']); But I find it ugly code (combining two arrays just to add a single item to the end of the first array).

The concat() method can be given a single (or multiple) values without the need of encapsulating the value(s) in an array first, for example:

['a', 'b'].concat('c');   // instead of .concat(['c']);

From MDN (my emphasis):

Arrays and/or values to concatenate into a new array.

Besides from that there are limited options without using extension and existing methods.

Example on how to extend the Array (this will return current array though):

Array.prototype.append = function(item) {
  this.push(item);
  return this
};

var a = [1, 2, 3];
console.log(a.append(4))

Optionally create a simple function as @torazaburo suggests, which can take array and item as argument:

function append(arr, item) {
  arr.push(item);
  return arr;
}

or using concat():

function append(arr, item) {
  return arr.concat(item)
}
2 of 2
0

I can offer two methods for Array.prototype.insert() which will allow you insert single or multiple elements starting from any index within the array.

1) mutates the array it's called upon and returns it

Array.prototype.insert = function(i,...rest){
  this.splice(i,0,...rest)
  return this
}

var a = [3,4,8,9];
console.log(JSON.stringify(a.insert(2,5,6,7)));

ES5 compliant version of the above snippet.

Array.prototype.insert = function(i){
  this.splice.apply(this,[i,0].concat(Array.prototype.slice.call(arguments,1)));
  return this;
};

2) Not mutates the array it's called upon and returns a new one

Array.prototype.insert = function(i,...rest){
  return this.slice(0,i).concat(rest,this.slice(i));
}

var a = [3,4,8,9],
    b = a.insert(2,5,6,7);
console.log(JSON.stringify(a));
console.log(JSON.stringify(b));

ES5 compliant version of the above snippet.

Array.prototype.insert = function(i){
  return this.slice(0,i).concat(Array.prototype.slice.call(arguments,1),this.slice(i));
}
🌐
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).
🌐
HostingAdvice
hostingadvice.com › home › how-to › javascript "add to array" functions (push vs unshift vs others)
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:
🌐
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...
🌐
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?
🌐
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
2 weeks ago - Use push(), spread syntax, concat(), or the length property to add one or more items to a JavaScript array