Lodash _.concat() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.concat(array, ...values) flattens arguments one level into a new array.
  • When nested arrays stay nested versus when their elements are spliced in.
  • How to import concat and compare with the spread operator.
  • Try each example in the editor (?tryit=1, 2, 3) with Lodash from a CDN.
  • Shallow-copy pitfalls when mutating shared objects.

Prerequisites

Arrays and rest/spread syntax help; optional prior pages _.chunk() and _.compact().

  • You know that [1, 2].concat([3]) in native JavaScript produces a new array.
  • You can run snippets in Node or open the Try-it labs in a browser.

Overview

_.concat builds a new array starting from the first argument, then appends every following value. If a following value is itself an array, its elements are appended in order (same rule as Array.prototype.concat).

Non-destructive

The first array is never mutated; you always receive a fresh array instance.

Combine lists

Typical for merging base rows with extra IDs, tags, or route segments.

Shallow only

Nested objects or arrays are not cloned; references are shared with the sources.

Syntax

javascript
_.concat(array, [values])
  • array: starting collection (array-like values are coerced).
  • values: any number of additional values or arrays; arrays contribute their elements.
  • Returns: a new concatenated array.
1

Primitives and arrays

Numbers and array arguments are flattened one level into the result.

javascript
import concat from "lodash/concat";

const merged = concat([1], 2, [3]);
// [1, 2, 3]
Try it Yourself
2

Nested array preserved

Passing [[2]] appends that array’s only element, which is the inner array [2].

javascript
import concat from "lodash/concat";

concat([1], [[2]]);
// [1, [2]]
Try it Yourself
3

Empty start

You can begin from an empty array and only append later arguments.

javascript
import concat from "lodash/concat";

concat([], [1, 2], 3);
// [1, 2, 3]
Try it Yourself

📋 _.concat vs spread

ApproachWhen it shinesTrade-off
_.concat(a, b, c)Variadic helper with consistent Lodash coercionExtra import in modern bundles
[...a, ...b, c]Native, terse, great with typed pipelinesSpread only works on iterables; mental model differs for nested arrays

Pitfalls to avoid

Mutation

Shared object references

If you mutate an object that still lives inside the original array, the concatenated array sees the same change.

Depth

Expecting deep merge

concat is not merge or union; it only sequences elements. Nested structures are not recursively flattened.

Arguments

Order matters

Arguments are appended left to right; swapping arrays changes the final ordering of duplicates.

❓ FAQ

No. Lodash returns a new array. The original array you pass as the first argument is unchanged.
Each argument after the first is appended. If an argument is an array, its elements are appended in order. A value like [[2]] is one array argument whose single element is the inner array [2], so the result contains [2] as one item.
They follow the same flattening rules for arguments. Lodash wraps the same idea with a stable API and works with array-like values after coercion.
Use import concat from "lodash/concat" or require("lodash/concat") for tree-shaking friendly bundles.
No. References are copied shallowly; objects inside the source arrays appear by reference in the new array.

Summary

Did you know?

_.concat does not mutate the first array. Arguments that are arrays contribute their elements (one level); a nested array like [[2]] contributes a single element [2] to the result.

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