| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/String/concat | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since 20157.
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"
concat(str1)
concat(str1, str2)
concat(str1, str2, ... , strN)
strN str
concat()
let hello = "Hello, ";
console.log(hello.concat("Kevin", ". Have a nice day."));
// Hello, Kevin. Have a nice day.
let greetList = ["Hello", " ", "Venkat", "!"];
"".concat(...greetList); // "Hello Venkat!"
"".concat({}); // [object Object]
"".concat([]); // ""
"".concat(null); // "null"
"".concat(true); // "true"
"".concat(4, 5); // "45"
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-string.prototype.concat |
This page was last modified on 2026526 by MDN contributors.
Stringanchor()at()big()blink()bold()charAt()charCodeAt()codePointAt()String.prototype.concat()endsWith()fixed()fontcolor()fontsize()includes()indexOf()isWellFormed()italics()lastIndexOf()link()String.prototype.localeCompare()match()matchAll()normalize()padEnd()String.prototype.padStart()repeat()replace()replaceAll()search()slice()small()split()startsWith()strike()sub()substr()substring()sup()toLocaleLowerCase()toLocaleUpperCase()String.prototype.toLowerCase()toString()toUpperCase()toWellFormed()String.prototype.trim()trimEnd()trimStart()valueOf()[Symbol.iterator]()Object/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |