String.prototype.concat()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

concat() メソッドは、文字列引数を呼び出し文字列に連結して、新しい文字列を返します。

試してみましょう

const str1 = "Hello";
const str2 = "World";

console.log(str1.concat(" ", str2));
// Expected output: "Hello World"

console.log(str2.concat(", ", str1));
// Expected output: "World, Hello"

構文

js
concat(str1)
concat(str1, str2)
concat(str1, str2, /* …, */ strN)

引数

strN

str に連結する 1 つ以上の文字列です。

返値

提供された文字列を結合したテキストの入った新しい文字列です。

解説

concat() 関数は、文字列引数を呼び出し文字列に連結し、新しい文字列を返します。元の文字列または返された文字列を変更しても、他の文字列には影響しません。

引数が文字列型でない場合は、連結前に文字列値に変換されます。

concat() メソッドは加算/文字列結合演算子 (+, +=) にとても似ていますが、concat()引数を直接文字列に変換するのに対し、加算演算子はオペランドをまずプリミティブに変換します。詳しくは、 + 演算子のリファレンスページを参照してください。

concat() の使用

複数の文字列を連結してコンソールに表示する例を以下に示します。

js
const hello = "こんにちは、";
console.log(hello.concat("鈴木さん", "。良い日を。"));
// Hello, Kevin. Have a nice day.

const greetList = ["こんにちは", " ", "佐藤さん", "!"];
"".concat(...greetList); // "こんにちは 佐藤さん!"

"".concat({}); // "[object Object]"
"".concat([]); // ""
"".concat(null); // "null"
"".concat(true); // "true"
"".concat(4, 5); // "45"

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-string.prototype.concat

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
concat

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報