[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String/concat [Back]  [Original]

String.prototype.concat() - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

String.prototype.concat()

Baseline

20157

concat() String

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

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

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

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

str1, , strN

str 1 String.prototype.concat() Array.prototype.concat()

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"

ECMAScript 2027 LanguageSpecification
# sec-string.prototype.concat


Web Proxy Viewer  |  New URL  |  Original Page