Lodash _.join() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Array

Definition

Converts all elements in an array into a string, inserting a separator between each pair. Default separator is a comma. Part of Lodash 4.x Array (since 4.0.0).

Pass the required arguments shown below. Lodash Array helpers usually return a new value — check whether the source array is mutated.

Syntax

Call _.join on an array. Start with this line.

Lodash
_.join(array, [separator=','])
CallWhat it does
_.join(array, [separator=','])Primary signature.
_.join(array)Call with an array argument.

Prefer import join from "lodash/join" when you want a smaller bundle.

Library declarations
Lodash
_.join(array, [separator=','])

Parameters

ParameterDescription
arrayRequired. Collection to convert
separatorOptional. Delimiter between elements; default ','

Return Value

Return ValueDescription
*Joined string

Lodash Examples

Example 1 — Official: Custom Separator

Join three letters with a tilde.

Lodash
_.join(['a', 'b', 'c'], '~');
// → 'a~b~c'
Try It Yourself

How It Works

  1. Elements. Three strings: a, b, c.
  2. Separator. '~' goes between each pair.
  3. Result. One string a~b~c.
  4. Source. The original array is not modified.

Example 2 — Default Comma

Omit the separator to get CSV-style commas.

Lodash
_.join(['a', 'b', 'c']);
// → 'a,b,c'
Try It Yourself

How It Works

  1. Default. Second argument omitted → separator is ','.
  2. Join. Insert commas between elements.
  3. Result. a,b,c.
  4. Same idea. Matches native ['a','b','c'].join() for plain arrays.

Example 3 — Space Separator

Build a readable phrase from word parts.

Lodash
_.join(['Hello', 'Lodash', 'world'], ' ');
// → 'Hello Lodash world'
Try It Yourself

How It Works

  1. Separator. A single space character.
  2. Words. Each element becomes a word in the phrase.
  3. Result. Hello Lodash world.
  4. Tip. Use '' (empty string) to concatenate with no gap.

Example 4 — null / undefined Slots

Missing values become empty pieces — separators still appear.

Lodash
_.join(['a', null, 'c', undefined], ',');
// → 'a,,c,'
Try It Yourself

How It Works

  1. Slots. null and undefined stringify as "".
  2. Separators stay. You still get a comma for each gap.
  3. Result. a,,c, — empty piece in the middle and at the end.
  4. Clean first? Use _.compact before joining if you want to drop falsey values.

Example 5 — Empty Array & Single Element

Edge sizes still return a string — no throw.

Lodash
_.join([], '-');
// → ''

_.join(['only'], '-');
// → 'only'
Try It Yourself

How It Works

  1. Empty. No elements → empty string "".
  2. One element. No separator is inserted — just that value as text.
  3. Safe. Useful when building paths or labels from optional lists.
  4. Numbers work. Non-strings are converted with String(…).

Browser & Runtime Support

_.join is a Lodash 4.x Array helper (added in 4.0.0). It runs anywhere Lodash runs — modern browsers (via CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 4.0.0+

_.join()

Available in [email protected] full builds and the lodash/join modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 4.0.0+
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
_.join Lodash 4.0.0+

Bottom line: Safe for production once Lodash 4.0.0+ is on the page or in your bundle. Prefer import join from "lodash/join" for smaller builds. Native Array.prototype.join is an equivalent for plain arrays.

Frequently Asked Questions

_.join(array, [separator=',']) converts all elements in array into a single string, inserting separator between each pair. It returns a string and does not mutate the array.
A comma. Omitting the second argument (or passing undefined) uses ',' — same default idea as Array.prototype.join.
They become empty string segments. Adjacent empties produce consecutive separators (for example 'a,,c').
For ordinary arrays the result matches Array.prototype.join with the same separator. Lodash is useful for a consistent API and modular imports alongside other helpers.
No. It only reads elements and returns a new string.
Use import join from "lodash/join" or require("lodash/join") for tree-shaking friendly bundles. Full build: import _ from "lodash" then _.join.

Next: _.last()

Get the last element of an array — Lodash’s right-end counterpart to _.head.

_.last() 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.

10 people found this page helpful