From bf8e099b9c8b3c60d60b3712b4fc97b052c39887 Mon Sep 17 00:00:00 2001 From: julieng Date: Tue, 3 Aug 2021 08:03:23 +0200 Subject: convert content to md --- .../global_objects/string/concat/index.md | 103 ++++++++------------- 1 file changed, 38 insertions(+), 65 deletions(-) (limited to 'files/fr/web/javascript/reference/global_objects/string/concat') diff --git a/files/fr/web/javascript/reference/global_objects/string/concat/index.md b/files/fr/web/javascript/reference/global_objects/string/concat/index.md index 8958a7491f..10583c89a1 100644 --- a/files/fr/web/javascript/reference/global_objects/string/concat/index.md +++ b/files/fr/web/javascript/reference/global_objects/string/concat/index.md @@ -10,36 +10,35 @@ tags: translation_of: Web/JavaScript/Reference/Global_Objects/String/concat original_slug: Web/JavaScript/Reference/Objets_globaux/String/concat --- -
{{JSRef}}
+{{JSRef}} -

La méthode concat() combine le texte de plusieurs chaînes avec la chaîne appelante et renvoie la nouvelle chaîne ainsi formée.

+La méthode **`concat()`** combine le texte de plusieurs chaînes avec la chaîne appelante et renvoie la nouvelle chaîne ainsi formée. -
{{EmbedInteractiveExample("pages/js/string-concat.html")}}
+{{EmbedInteractiveExample("pages/js/string-concat.html")}} -

Syntaxe

+## Syntaxe -
str.concat(string2[, string3, ..., stringN])
+ str.concat(string2[, string3, ..., stringN]) -

Paramètres

+### Paramètres -
-
string2...stringN
-
Chaînes de caractères à concaténer ensemble.
-
+- `string2...stringN` + - : Chaînes de caractères à concaténer ensemble. -

Valeur de retour

+### Valeur de retour -

Une nouvelle chaîne de caractères qui contient la concaténation des chaînes de caractères fournies.

+Une nouvelle chaîne de caractères qui contient la concaténation des chaînes de caractères fournies. -

Description

+## Description -

La fonction concat() renvoie une nouvelle chaîne correspondant à la concaténation des différents arguments avec la chaîne courante. La chaîne courante est celle sur laquelle a été appelée la méthode concat(). Si les valeurs passées en arguments ne sont pas des chaînes de caractères, elles sont automatiquement converties en chaînes (grâce à leur méthode toString() avant la concaténation).

+La fonction `concat()` renvoie une nouvelle chaîne correspondant à la concaténation des différents arguments avec la chaîne courante. La chaîne courante est celle sur laquelle a été appelée la méthode `concat()`. Si les valeurs passées en arguments ne sont pas des chaînes de caractères, elles sont automatiquement converties en chaînes (grâce à leur méthode `toString()` avant la concaténation). -

Exemples

+## Exemples -

L'exemple suivant combine plusieurs chaînes afin d'en former une nouvelle.

+L'exemple suivant combine plusieurs chaînes afin d'en former une nouvelle. -
var coucou = "Bonjour ";
+```js
+var coucou = "Bonjour ";
 console.log(coucou.concat("Tristan,", " bonne journée."));
 
 /* Bonjour Tristan, bonne journée. */
@@ -52,52 +51,26 @@ var salutation = ['Bonjour', ' ', 'Alfred', ' ', '!'];
 "".concat(null); // "null"
 "".concat(true); // "true"
 "".concat(4, 5); // "45"
+```
 
-
- -

Performance

- -

Il est fortement recommandé d'utiliser les {{jsxref("Opérateurs/Opérateurs_d_affectation", "opérateurs d'affectation", "", 1)}} (+, +=) plutôt que la méthode concat() pour des raisons de performance.

- -

Spécifications

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SpécificationÉtatCommentaires
{{SpecName('ES3')}}{{Spec2('ES3')}}Définition initiale. Implémentée avec JavaScript 1.2.
{{SpecName('ES5.1', '#sec-15.5.4.6', 'String.prototype.concat')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-string.prototype.concat', 'String.prototype.concat')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-string.prototype.concat', 'String.prototype.concat')}}{{Spec2('ESDraft')}}
- -

Compatibilité des navigateurs

- -

{{Compat("javascript.builtins.String.concat")}}

- -

Voir aussi

- - +## Performance + +Il est fortement recommandé d'utiliser les {{jsxref("Opérateurs/Opérateurs_d_affectation", "opérateurs d'affectation", "", 1)}} (+, +=) plutôt que la méthode `concat()` pour des raisons de performance. + +## Spécifications + +| Spécification | État | Commentaires | +| ------------------------------------------------------------------------------------------------------------ | ---------------------------- | ----------------------------------------------------- | +| {{SpecName('ES3')}} | {{Spec2('ES3')}} | Définition initiale. Implémentée avec JavaScript 1.2. | +| {{SpecName('ES5.1', '#sec-15.5.4.6', 'String.prototype.concat')}} | {{Spec2('ES5.1')}} | | +| {{SpecName('ES6', '#sec-string.prototype.concat', 'String.prototype.concat')}} | {{Spec2('ES6')}} | | +| {{SpecName('ESDraft', '#sec-string.prototype.concat', 'String.prototype.concat')}} | {{Spec2('ESDraft')}} | | + +## Compatibilité des navigateurs + +{{Compat("javascript.builtins.String.concat")}} + +## Voir aussi + +- {{jsxref("Array.prototype.concat()")}} +- {{jsxref("Opérateurs/Opérateurs_d_affectation", "Les opérateurs d'affectation", "", 1)}} -- cgit v1.2.3-54-g00ecf