JavaScript文字列concat()
例
2つの文字列を結合します。
let text1 = "sea";
let text2 = "food";
let result = text1.concat(text2);
2つの文字列を結合します。
let text1 = "Hello";
let text2 = "world!";
let result = text1.concat(" ", text2);
以下のその他の例。
定義と使用法
concat()
メソッドは2つ以上の文字列を結合します。
このconcat()
メソッドは既存の文字列を変更しません。
このconcat()
メソッドは新しい文字列を返します。
構文
string.concat(string1, string2, ..., stringX)
パラメーター
Parameter | Description |
string1, string2, ... stringX | Required. The strings to be joined. |
戻り値
タイプ | 説明 |
文字列 | 結合された文字列を含む新しい文字列。 |
その他の例
3つの文字列を結合します。
let text1 = "Hello";
let text2 = "world!";
let text3 = "Have a nice day!";
let result = text1.concat(" ", text2, " ", text3);
ブラウザのサポート
concat()
ECMAScript1(ES1)機能です。
ES1(JavaScript 1997)は、すべてのブラウザーで完全にサポートされています。
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |