JavaScript Array concat() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Array merge

What You’ll Learn

The concat() method merges arrays into a new array without touching the originals. This tutorial covers syntax, five worked examples, comparisons with spread syntax, shallow-copy behavior, and when to pick concat over mutating helpers like push.

01

Syntax

arr.concat(...)

02

Merge

Two+ arrays

03

Immutable

New array only

04

Values

Non-arrays OK

05

Shallow

One-level copy

06

vs Spread

[...a, ...b]

Introduction

Arrays often need to be combined—merging a shopping cart with saved items, joining paginated API results, or building a playlist from multiple sources. The concat() method is the classic, non-destructive way to do that in JavaScript.

Unlike push or splice, concat() never changes the arrays you pass in. It returns a fresh array containing every element in order.

Understanding the concat() Method

concat() walks each argument: if the argument is an array (or array-like with a length), its elements are appended; otherwise the value itself becomes one new slot in the result.

Reach for concat when you want a merged snapshot without side effects. In modern code, [...first, ...second] is equally common—both produce a shallow, one-level merge.

💡
Beginner Tip

After const merged = a.concat(b), changing merged does not alter a or b. But if an element is an object, both arrays still reference the same object in memory.

📝 Syntax

General form of Array.prototype.concat:

JavaScript
const newArray = array1.concat(array2, array3, value1, value2);

Parameters

  • array1 — the array you call the method on (the starting elements).
  • array2, array3, … — optional arrays whose elements are appended in order.
  • value1, value2, … — optional non-array values appended as single elements.

Return value

  • A new array containing all merged elements.
  • Original arrays remain unchanged.

Common patterns

  • a.concat(b) — merge two arrays.
  • a.concat(b, c) — merge three or more in one call.
  • [].concat(original) — shallow copy trick.

⚡ Quick Reference

GoalCode
Merge two arraysa.concat(b)
Merge three arraysa.concat(b, c)
Append one valuearr.concat("extra")
Shallow copy[].concat(arr)
Mutates originals?No

📋 concat() vs Spread vs push

Pick the style that fits your codebase—behavior for merging is similar, but mutation differs.

concat
a.concat(b)

New array, classic API

Spread
[...a, ...b]

New array, ES2015+

push spread
a.push(...b)

Mutates a

Nested
one level only

Use flat() deeper

Examples Gallery

Open DevTools Console (F12) and paste each snippet, or use the Try-it links. Example numbers match lab numbers (?tryit=1 through 5).

📚 Getting Started

Basic merges with fruit arrays.

Example 1 — Merge Two Arrays

Combine fruits1 and fruits2 into a new list.

JavaScript
const fruits1 = ["apple", "orange"];
const fruits2 = ["banana", "grape"];

const mergedFruits = fruits1.concat(fruits2);

console.log(mergedFruits);
// ["apple", "orange", "banana", "grape"]

console.log(fruits1); // unchanged: ["apple", "orange"]
Try It Yourself

How It Works

concat copies elements from fruits1, then appends every element from fruits2. Neither source array is modified.

Example 2 — Merge Three Arrays at Once

Pass multiple array arguments in a single concat call.

JavaScript
const fruits1 = ["apple", "orange"];
const fruits2 = ["banana", "grape"];
const moreFruits = ["kiwi", "mango"];

const mergedFruits = fruits1.concat(fruits2, moreFruits);

console.log(mergedFruits);
// ["apple", "orange", "banana", "grape", "kiwi", "mango"]
Try It Yourself

How It Works

Arguments are processed left to right. This is equivalent to fruits1.concat(fruits2).concat(moreFruits) but reads cleaner.

📈 Practical Patterns

Copies, value appends, and conditional merges.

Example 3 — Shallow Copy with [].concat()

Create a new top-level array that mirrors the original.

JavaScript
const originalArray = [1, 2, 3];
const copiedArray = [].concat(originalArray);

copiedArray.push(4);

console.log(copiedArray);    // [1, 2, 3, 4]
console.log(originalArray);  // [1, 2, 3]
Try It Yourself

How It Works

Calling concat on an empty array with one argument copies the top-level slots. Nested objects inside are still shared (shallow copy).

Example 4 — Append Individual Values

Non-array arguments become single elements in the result.

JavaScript
const nums = [1, 2];
const extended = nums.concat(3, 4, 5);

console.log(extended);
// [1, 2, 3, 4, 5]

const withLabel = ["a", "b"].concat("separator", ["c", "d"]);
console.log(withLabel);
// ["a", "b", "separator", "c", "d"]
Try It Yourself

How It Works

Primitives are appended as-is. Arrays still expand one level—"separator" stays one string element between two arrays.

Example 5 — Conditional Dynamic Merge

Merge extra items only when a flag is true.

JavaScript
const selectedFruits = ["apple", "banana"];
const tropicalFruits = ["kiwi", "mango"];
const shouldIncludeTropical = true;

const finalFruits = selectedFruits.concat(
  shouldIncludeTropical ? tropicalFruits : []
);

console.log(finalFruits);
// ["apple", "banana", "kiwi", "mango"]
Try It Yourself

How It Works

The ternary passes either tropicalFruits or an empty array. An empty array adds nothing—a clean pattern for optional segments in pipelines.

🚀 Common Use Cases

  • Immutable merges — build new lists in Redux-style reducers without mutating state.
  • Pagination — append the next page: allItems.concat(nextPage).
  • Shallow clones — duplicate a top-level array before editing.
  • Default + user data — concat defaults with user selections.
  • Legacy compatibility — works in every JavaScript environment, including very old browsers.
  • Functional pipelines — chain with map/filter without side effects.

🧠 How concat() Builds the Result

1

Copy caller

Start with a new array containing elements from the array you invoked concat on.

Base
2

Process args

For each argument: spread array elements, or push a single value.

Append
3

Return new array

Hand back the merged result; originals stay untouched.

Immutable
4

Shallow only

Nested arrays stay nested; inner objects are shared by reference.

📝 Notes

  • concat() flattens only one level of array arguments.
  • For deep clones, use structured cloning, a library, or recursive copy—not concat alone.
  • Array.prototype.concat is not the same as String.prototype.concat (strings behave differently).
  • Spread syntax cannot easily append a single array as one nested element without wrapping it: [...a, b] spreads b.
  • Empty arrays as arguments are harmless—they add zero elements.
  • Performance: for very large arrays, consider pre-allocating or using loops if profiling shows a bottleneck.

Browser & Runtime Support

Array.prototype.concat() has been part of JavaScript since ES3 and is supported in every browser and Node.js version you are likely to encounter.

Baseline · Since ES3

Array.prototype.concat()

Supported in all modern and legacy browsers, including Internet Explorer 6+. No polyfill required.

100% Universal support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.concat() Universal

Bottom line: One of the oldest, most portable array methods. Safe to use anywhere JavaScript runs.

Conclusion

The concat() method is a dependable, immutable way to merge arrays and append values. It keeps your source data intact while producing a fresh combined list.

Practice the examples until a.concat(b) and [...a, ...b] both feel natural—then pick whichever reads clearer in your project.

💡 Best Practices

✅ Do

  • Use concat when you need a new array without mutation
  • Pass multiple arrays in one call when merging several lists
  • Remember the copy is shallow for nested data
  • Prefer spread in modern code if your team style guide favors it
  • Use [].concat(arr) for a quick top-level clone

❌ Don’t

  • Expect deep cloning from concat alone
  • Assume nested arrays flatten fully—use flat() instead
  • Mutate shared inner objects after copying unless intentional
  • Chain many concats in hot loops without measuring performance
  • Confuse string concat with array concat

Key Takeaways

Knowledge Unlocked

Five things to remember about Array.concat()

Your foundation for non-destructive array merging.

5
Core concepts
🔗 02

Immutable

New array only.

Safe merge
🗃 03

Shallow

One level deep.

Copy
04

Values OK

Not just arrays.

Flexible
🌐 05

Universal

ES3 support.

Portable

❓ Frequently Asked Questions

concat() merges the calling array with zero or more arrays or values and returns a new array. The original arrays are not modified.
No. concat() always returns a fresh array. Source arrays keep their original elements and order.
Shallow. Nested arrays and objects are copied by reference into the new array—inner structures are shared, not cloned.
[...a, ...b] builds a new array similarly and is idiomatic in modern JavaScript. concat() accepts multiple arguments in one call and works the same way on the Array prototype.
Yes. Each argument is appended as a single element unless it is an array (or array-like), in which case its elements are flattened one level into the result.
Only one level. concat([1, [2, 3]]) yields [1, [2, 3]]. Use flat() when you need deeper flattening.
Did you know?

Calling [].concat(myArray) is a classic one-liner for a shallow array copy—years before spread syntax existed, developers used this trick daily.

Continue to copyWithin()

Learn how to copy a sequence of elements within the same array in place.

copyWithin() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful