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]
Fundamentals
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.
Concept
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.
The ternary passes either tropicalFruits or an empty array. An empty array adds nothing—a clean pattern for optional segments in pipelines.
Applications
🚀 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.
Important
📝 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.
Compatibility
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 ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Array.concat()Universal
Bottom line: One of the oldest, most portable array methods. Safe to use anywhere JavaScript runs.
Wrap Up
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.
Mutate shared inner objects after copying unless intentional
Chain many concats in hot loops without measuring performance
Confuse string concat with array concat
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Array.concat()
Your foundation for non-destructive array merging.
5
Core concepts
📝01
Syntax
a.concat(b, c)
API
🔗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.