| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/String/concat | [Back] [Original] |
Get to know MDN better
Cette page a t traduite partir de l'anglais par la communaut. Vous pouvez contribuer en rejoignant la communaut francophone sur MDN Web Docs.
Cette fonctionnalit est bien tablie et fonctionne sur de nombreux appareils et versions de navigateurs. Elle est disponible sur tous les navigateurs depuis juillet 2015.
La mthode concat() combine le texte de plusieurs chanes avec la chane appelante et renvoie la nouvelle chane ainsi forme.
const str1 = "Hello";
const str2 = "World";
console.log(str1.concat(" ", str2));
// Expected output: "Hello World"
console.log(str2.concat(", ", str1));
// Expected output: "World, Hello"
str.concat(string2[, string3, ..., stringN])
string2...stringNChanes de caractres concatner ensemble.
Une nouvelle chane de caractres qui contient la concatnation des chanes de caractres fournies.
La fonction concat() renvoie une nouvelle chane correspondant la concatnation des diffrents arguments avec la chane courante. La chane courante est celle sur laquelle a t appele la mthode concat(). Si les valeurs passes en arguments ne sont pas des chanes de caractres, elles sont automatiquement converties en chanes (grce leur mthode toString() avant la concatnation).
L'exemple suivant combine plusieurs chanes afin d'en former une nouvelle.
var coucou = "Bonjour ";
console.log(coucou.concat("Tristan,", " bonne journe."));
/* Bonjour Tristan, bonne journe. */
var salutation = ["Bonjour", " ", "Alfred", " ", "!"];
"".concat(...salutation); // "Bonjour Alfred !"
"".concat({}); // [object Object]
"".concat([]); // ""
"".concat(null); // "null"
"".concat(true); // "true"
"".concat(4, 5); // "45"
Il est fortement recommand d'utiliser les oprateurs d'affectation (+, +=) plutt que la mthode concat() pour des raisons de performance.
| Spcification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-string.prototype.concat |
Cette page a t modifie le 22 mai 2026 par les contributeurices du MDN.
StringString.prototype.anchor()String.prototype.at()String.prototype.big()String.prototype.blink()String.prototype.bold()String.prototype.charAt()String.prototype.charCodeAt()String.prototype.codePointAt()String.prototype.concat()String.prototype.endsWith()String.prototype.fixed()String.prototype.fontcolor()String.prototype.fontsize()String.prototype.includes()String.prototype.indexOf()isWellFormed()String.prototype.italics()String.prototype.lastIndexOf()String.prototype.link()String.prototype.localeCompare()String.prototype.match()String.prototype.matchAll()String.prototype.normalize()String.prototype.padEnd()String.prototype.padStart()String.prototype.repeat()String.prototype.replace()String.prototype.replaceAll()String.prototype.search()String.prototype.slice()String.prototype.small()String.prototype.split()String.prototype.startsWith()String.prototype.strike()String.prototype.sub()String.prototype.substr()String.prototype.substring()String.prototype.sup()String.prototype.toLocaleLowerCase()String.prototype.toLocaleUpperCase()String.prototype.toLowerCase()String.prototype.toString()String.prototype.toUpperCase()toWellFormed()String.prototype.trim()String.prototype.trimEnd()String.prototype.trimStart()String.prototype.valueOf()String.prototype[@@iterator]()Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Certaines parties de ce contenu sont protges par le droit d'auteur 19982026 des contributeurs individuels de mozilla.org. Contenu disponible sous une licence Creative Commons.
| Web Proxy Viewer | New URL | Original Page |