JavaScript String concat() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

In JavaScript, String.prototype.concat() joins the current string with one or more values and returns a new string. The original string never changes. Non-string arguments are converted to text first.

Remember
str.concat(a, b, ...)  → new joined string
original string         → unchanged
numbers / booleans      → become text
"Hi" + "!"              → often clearer than concat

Syntax

Call concat on the string you already have. You can pass one value or many.

JavaScript
str.concat(str2);
str.concat(str2, str3);
CallWhat it does
str.concat(str2)Joins str and str2 into one new string.
str.concat(str2, str3)Joins three (or more) pieces left to right in one call.

Built into JavaScript. Call concat(...) on a string — no import needed. For everyday code, the + operator is usually clearer.

Library declarations
JavaScript
str.concat(str2)
str.concat(str2, str3, ...strN)

Parameters

ParameterDescription
str2, str3, …Optional. One or more values to append. Each value is converted to a string.

Return Value

Return ValueDescription
stringA new string made of the original text plus every argument, in order.

JavaScript Examples

Example 1 — Basic concat()

Join a greeting and a name into one string.

JavaScript
const hello = "Hello";
const name = "Ada";

const message = hello.concat(", ", name, "!");
console.log(message);
console.log(hello);
Try It Yourself

How It Works

  1. Start with pieces. hello and name are separate strings.
  2. Join in order. concat(", ", name, "!") builds "Hello, Ada!".
  3. Original stays put. hello is still "Hello" because strings do not mutate.

Example 2 — Numbers and Other Values

Non-string arguments become text before they are joined.

JavaScript
const label = "Score: ";

console.log(label.concat(42));
console.log("Done: ".concat(true));
console.log("Items: ".concat(1, "-", 3));
Try It Yourself

How It Works

  1. Numbers become text. 42 is written as "42" inside the result.
  2. Booleans too. true becomes the string "true".
  3. Many args work. Each argument is converted, then joined left to right.

Example 3 — concat() vs +

Both join strings. Prefer + (or template literals) in most beginner code.

JavaScript
const a = "Code";
const b = "ToFun";

console.log(a.concat(b));
console.log(a + b);
console.log(`${a}${b}`);
Try It Yourself

How It Works

  1. Same result. All three lines print CodeToFun.
  2. Choose clarity. + and template literals are easier to read for most joins.
  3. When concat helps. Use it when you already have an array of pieces and call "".concat(...parts).

Browser & Runtime Support

String.prototype.concat() has been available since the earliest JavaScript engines. Safe everywhere.

✓ Baseline · Widely available

String.concat()

Supported in all modern browsers and Node.js. No polyfill needed.

100% Modern browser 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
concat() Excellent

Bottom line: Safe for every environment. Prefer + or template literals for everyday string joining.

Frequently Asked Questions

It joins the current string with one or more values and returns a new string. The original string is not changed.
No. Strings are immutable. Assign the return value if you need the joined text.
Yes. Numbers, booleans, and most other values are converted to strings, then joined.
For two or three pieces, + or a template literal is usually clearer. concat() is handy when joining many arguments or spreading an array.
You get a copy of the original string as a new string value.

Next: endsWith()

Learn how to test whether a string ends with a given suffix.

endsWith() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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